Freigeben über


SectionInformation.AllowLocation Eigenschaft

Definition

Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob der Konfigurationsabschnitt das location Attribut zulässt.

public:
 property bool AllowLocation { bool get(); void set(bool value); };
public bool AllowLocation { get; set; }
member this.AllowLocation : bool with get, set
Public Property AllowLocation As Boolean

Eigenschaftswert

true wenn das location Attribut zulässig ist; andernfalls false. Der Standardwert lautet true.

Ausnahmen

Der ausgewählte Wert steht in Konflikt mit einem bereits definierten Wert.

Beispiele

Die Beispiele in diesem Abschnitt zeigen, wie Sie den AllowLocation Eigenschaftswert nach dem Zugriff auf die zugehörigen Abschnittsinformationen in der Konfigurationsdatei abrufen.

Das folgende Beispiel ruft das SectionInformation Objekt ab.

// Get the current configuration file.
System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

// Get the section.
UrlsSection section =
    (UrlsSection)config.GetSection("MyUrls");

SectionInformation sInfo =
    section.SectionInformation;
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)

' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)

Dim sInfo As SectionInformation = _
section.SectionInformation

Im folgenden Beispiel wird der AllowLocation Wert abgerufen.

bool allowLocation =
    sInfo.AllowLocation;
Console.WriteLine("Allow location: {0}",
               allowLocation.ToString());
Dim allowLocation As Boolean = _
sInfo.AllowLocation
Console.WriteLine("Allow location: {0}", _
allowLocation.ToString())

Hinweise

Wenn diese Eigenschaft auf Eigenschaft an, dass der Abschnitt von systemeigenen Codelesern aufgerufen wird. Daher ist die Verwendung des location Attributs nicht zulässig, da die systemeigenen Codeleser das Konzept von location.

Gilt für: