SectionInformation.IsDeclarationRequired Właściwość

Definicja

Pobiera wartość wskazującą, czy sekcja konfiguracji musi być zadeklarowana w pliku konfiguracji.

public:
 property bool IsDeclarationRequired { bool get(); };
public bool IsDeclarationRequired { get; }
member this.IsDeclarationRequired : bool
Public ReadOnly Property IsDeclarationRequired As Boolean

Wartość właściwości

truejeśli skojarzony ConfigurationSection obiekt musi być zadeklarowany w pliku konfiguracji; w przeciwnym razie . false

Przykłady

W przykładach w tej sekcji pokazano, jak uzyskać IsDeclarationRequired wartość właściwości po dokonaniu dostępu do powiązanych informacji sekcji w pliku konfiguracji.

Poniższy przykład pobiera SectionInformation obiekt .

// 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

Poniższy przykład pobiera IsDeclarationRequired wartość.

bool declRequired = 
    sInfo.IsDeclarationRequired;
Console.WriteLine("Declaration required?: {0}",
    declRequired.ToString());
Dim declRequired As Boolean = _
sInfo.IsDeclarationRequired
Console.WriteLine("Declaration required?: {0}", _
declRequired.ToString())

Dotyczy

Zobacz też