SectionInformation.IsLocked 属性

定义

获取一个值,指示关联的配置节是否被锁定。

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

属性值

如果该节被锁定,则为 true;否则为 false

示例

本部分中的示例演示如何在访问配置文件中的相关节信息后获取 IsLocked 属性值。

以下示例获取 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

以下示例获取 IsLocked 值。

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

注解

IsLocked当相关节被 或 属性锁定时, AllowOverrideAllowDefinition 属性返回true。 如果无法在当前配置文件中重写或定义节,则会锁定该节。

适用于