SectionInformation.IsProtected Proprietà

Definizione

Ottiene un valore che indica se la sezione di configurazione associata è protetta.

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

Valore della proprietà

true se la classe ConfigurationSection è bloccata; in caso contrario, false. Il valore predefinito è false.

Esempio

Gli esempi in questa sezione illustrano come ottenere il valore della IsProtected proprietà dopo l'accesso alle informazioni della sezione correlate nel file di configurazione.

Nell'esempio seguente viene ottiene l'oggetto SectionInformation .

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

Nell'esempio seguente viene restituito il IsProtected valore .

bool protect =
    sInfo.IsProtected;
Console.WriteLine("Section protected?: {0}",
    protect.ToString());
Dim protect As Boolean = _
sInfo.IsProtected
Console.WriteLine("Section protected?: {0}", _
protect.ToString())

Commenti

Le sezioni di configurazione protette sono crittografate e di sola lettura.

Per altre informazioni sulle sezioni di configurazione protetta, vedere Crittografia delle informazioni di configurazione tramite la configurazione protetta.

Si applica a

Vedi anche