SectionInformation.AllowLocation 属性

定义

获取或设置一个值,指示配置节是否允许 location 特性。

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

属性值

如果允许 true 特性,则为 location;否则为 false。 默认值为 true

例外

选定值与某个已定义的值冲突。

示例

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

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

以下示例获取 AllowLocation 值。

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

注解

false设置为 时, AllowLocation 属性指示本机代码读取器访问节。 因此,不允许使用 location 特性,因为本机代码读取器不支持 的概念 location

适用于