ConfigurationLocation Klass

Definition

Representerar ett location element i en konfigurationsfil.

public ref class ConfigurationLocation
public class ConfigurationLocation
type ConfigurationLocation = class
Public Class ConfigurationLocation
Arv
ConfigurationLocation

Exempel

I följande kodexempel läses webbkonfigurationen för programmet MySampleApp in och sedan visas de platser som definierats i konfigurationen.

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

En instans av ConfigurationLocation klassen representerar ett enda location element i en konfigurationsfil. Platser används för att ange konfigurationsinställningar som endast gäller för en angiven resurs, till exempel en specifik sida, fil eller underkatalog i webbprogrammet. ConfigurationLocation Använd klassen för att hämta sökvägen och objektet Configuration som gäller för den angivna resursen.

Egenskaper

Name Description
Path

Hämtar den relativa sökvägen till resursen vars konfigurationsinställningar representeras av det här ConfigurationLocation objektet.

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
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)
OpenConfiguration()

Skapar en instans av ett konfigurationsobjekt.

ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för