ConfigurationLocationCollection Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Innehåller en samling ConfigurationLocationCollection objekt.
public ref class ConfigurationLocationCollection : System::Collections::ReadOnlyCollectionBase
public class ConfigurationLocationCollection : System.Collections.ReadOnlyCollectionBase
type ConfigurationLocationCollection = class
inherit ReadOnlyCollectionBase
Public Class ConfigurationLocationCollection
Inherits ReadOnlyCollectionBase
- Arv
Exempel
I följande kodexempel läses webbkonfigurationen för programmet MySampleApp in och de platser som definieras i den här konfigurationen visas genom iterering via objektet ConfigurationLocationCollection som returneras av Locations egenskapen.
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.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
Kommentarer
ConfigurationLocationCollection Använd klassen för att iterera via en samling ConfigurationLocation objekt, som representerar de resurser som platsspecifika konfigurationsinställningar definieras för. ConfigurationLocationCollection är den typ som returneras av egenskapen Locations .
Note
Klassen ConfigurationLocationCollection kanske inte refererar till samlingen med ConfigurationLocation objekt i den ordning som de anges i konfigurationsfilen.
Egenskaper
| Name | Description |
|---|---|
| Count |
Hämtar antalet element som finns i instansen ReadOnlyCollectionBase . (Ärvd från ReadOnlyCollectionBase) |
| InnerList |
Hämtar listan över element som finns i instansen ReadOnlyCollectionBase . (Ärvd från ReadOnlyCollectionBase) |
| Item[Int32] |
Hämtar objektet ConfigurationLocationCollection vid det angivna indexet. |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Avgör om det angivna objektet är lika med det aktuella objektet. (Ärvd från Object) |
| GetEnumerator() |
Returnerar en uppräkning som itererar genom instansen ReadOnlyCollectionBase . (Ärvd från ReadOnlyCollectionBase) |
| GetHashCode() |
Fungerar som standard-hash-funktion. (Ärvd från Object) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |
Explicita gränssnittsimplementeringar
| Name | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Kopierar hela ReadOnlyCollectionBase till en kompatibel endimensionell Array, med början vid det angivna indexet för målmatrisen. (Ärvd från ReadOnlyCollectionBase) |
| ICollection.IsSynchronized |
Hämtar ett värde som anger om åtkomsten till ett ReadOnlyCollectionBase objekt synkroniseras (trådsäker). (Ärvd från ReadOnlyCollectionBase) |
| ICollection.SyncRoot |
Hämtar ett objekt som kan användas för att synkronisera åtkomst till ett ReadOnlyCollectionBase objekt. (Ärvd från ReadOnlyCollectionBase) |
Tilläggsmetoder
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
Möjliggör parallellisering av en fråga. |
| AsQueryable(IEnumerable) |
Konverterar en IEnumerable till en IQueryable. |
| Cast<TResult>(IEnumerable) |
Omvandlar elementen i en IEnumerable till den angivna typen. |
| OfType<TResult>(IEnumerable) |
Filtrerar elementen i en IEnumerable baserat på en angiven typ. |