ConfigurationLocationCollection ConfigurationLocationCollection ConfigurationLocationCollection ConfigurationLocationCollection Class

Definition

Contains a collection of ConfigurationLocationCollection objects.

public ref class ConfigurationLocationCollection : System::Collections::ReadOnlyCollectionBase
public class ConfigurationLocationCollection : System.Collections.ReadOnlyCollectionBase
type ConfigurationLocationCollection = class
    inherit ReadOnlyCollectionBase
Public Class ConfigurationLocationCollection
Inherits ReadOnlyCollectionBase
Inheritance
ConfigurationLocationCollectionConfigurationLocationCollectionConfigurationLocationCollectionConfigurationLocationCollection

Examples

In the following code example, the Web configuration for the application MySampleApp is loaded, and the locations defined in this configuration are displayed by iterating through the ConfigurationLocationCollection object returned by the Locations property.

using System;
using System.Collections;
using System.Configuration;

class DisplayLocationInfo
{
    static void Main(string[] args)
    {
        Configuration config = 
            ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        ConfigurationLocationCollection myLocationCollection = config.Locations;
        foreach (ConfigurationLocation myLocation in myLocationCollection)
        {
            Console.WriteLine("Location Path: {0}", myLocation.Path);
            Configuration myLocationConfiguration = myLocation.OpenConfiguration();
            Console.WriteLine("Location Configuration File Path: {0}",
                myLocationConfiguration.FilePath);
        }
        Console.WriteLine("Done...");
        Console.ReadLine();
    }
}
Imports System
Imports System.Collections
Imports System.Configuration

Class DisplayLocationInfo
    Public Overloads Shared Sub Main()
        Dim config As System.Configuration.Configuration = _
            ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
        Dim myLocationCollection As _
            System.Configuration.ConfigurationLocationCollection = config.Locations
        Dim myLocation As ConfigurationLocation
        For Each myLocation In  myLocationCollection
            Console.WriteLine("Location Path: {0}", myLocation.Path)
            Dim myLocationConfiguration As System.Configuration.Configuration = _
                myLocation.OpenConfiguration()
            Console.WriteLine("Location Configuration Path: {0}", _
                myLocationConfiguration.FilePath)
        Next myLocation
        Console.WriteLine("Done...")
        Console.ReadLine()
    End Sub
End Class 'DisplayLocationInfo

Remarks

Use the ConfigurationLocationCollection class to iterate through a collection of ConfigurationLocation objects, which represent the resources for which location-specific configuration settings are defined. ConfigurationLocationCollection is the type returned by the Locations property.

Note

The ConfigurationLocationCollection class might not reference the collection of ConfigurationLocation objects in the order that they are specified in the configuration file.

Properties

Count Count Count Count

Gets the number of elements contained in the ReadOnlyCollectionBase instance.

(Inherited from ReadOnlyCollectionBase)
ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

Gets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe).

(Inherited from ReadOnlyCollectionBase)
ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

Gets an object that can be used to synchronize access to a ReadOnlyCollectionBase object.

(Inherited from ReadOnlyCollectionBase)
InnerList InnerList InnerList InnerList

Gets the list of elements contained in the ReadOnlyCollectionBase instance.

(Inherited from ReadOnlyCollectionBase)
Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets the ConfigurationLocationCollection object at the specified index.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the ReadOnlyCollectionBase instance.

(Inherited from ReadOnlyCollectionBase)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

Copies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

(Inherited from ReadOnlyCollectionBase)

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to