共用方式為


SectionInformation.AllowLocation 屬性

定義

取得或設定值,指出組態區段是否允許 location 屬性 (Attribute)。

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

適用於