SectionInformation.IsDeclarationRequired Propriedade

Definição

Recebe um valor que indica se a secção de configuração deve ser declarada no ficheiro de configuração.

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

Valor de Propriedade

true se o objeto associado ConfigurationSection tiver de ser declarado no ficheiro de configuração; caso contrário, false.

Exemplos

Os exemplos nesta secção mostram como obter o valor da IsDeclarationRequired propriedade após aceder à informação da secção relacionada no ficheiro de configuração.

O exemplo seguinte obtém o SectionInformation objeto.

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

O exemplo seguinte obtém o IsDeclarationRequired valor.

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

Aplica-se a

Ver também