SectionInformation 類別

定義

包含與組態階層架構內個別區段有關的中繼資料。 此類別無法獲得繼承。

public ref class SectionInformation sealed
public sealed class SectionInformation
type SectionInformation = class
Public NotInheritable Class SectionInformation
繼承
SectionInformation

範例

下列範例示範如何取得 SectionInformation 與 對象相關聯的 ConfigurationSection 元數據。

static public SectionInformation 
    GetSectionInformation()
{

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

    return sInfo;
}
Public Shared Function GetSectionInformation() _
As 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

    Return sInfo

End Function 'GetSectionInformation

下列範例是上一個範例所使用的組態檔摘錄。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="MyUrls" type="Samples.AspNet.UrlsSection,
      ConfigurationElement, Version=1.0.0.0, Culture=neutral,
      PublicKeyToken=null" allowDefinition="Everywhere"
      allowExeDefinition="MachineToApplication"
      restartOnExternalChanges="true" />
  </configSections>
  <MyUrls name="MyFavorites">
    <simple name="Contoso" url="http://www.contoso.com" port="8080" />
    <urls>
      <clear />
      <add name="Microsoft" url="http://www.microsoft.com" port="0" />
    </urls>
  </MyUrls>
</configuration>

備註

SectionInformation物件包含組態階層內個別區段的相關元數據。 這個物件可用來驗證和變更個別區段的屬性。

屬性

AllowDefinition

取得或設定值,指出可以在組態檔階層架構中的哪一個位置定義關聯的組態區段。

AllowExeDefinition

取得或設定值,指出可以在組態檔階層架構中的哪一個位置宣告關聯的組態區段。

AllowLocation

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

AllowOverride

取得或設定值,指出較低層級的組態檔是否可以覆寫關聯的組態區段。

ConfigSource

取得或設定關聯的組態區段定義所在的 Include 檔的名稱 (如果此檔案存在)。

ConfigurationBuilder

取得此設定區段的 ConfigurationBuilder 物件。

ForceSave

取得或設定值,指出即使在尚未修改關聯的組態區段時,是否也要儲存此區段。

InheritInChildApplications

取得或設定值,這個值會指出位於相關應用程式子目錄中的應用程式是否會繼承關聯組態區段中指定的設定。

IsDeclarationRequired

取得值,指出是否必須在組態檔中宣告組態區段。

IsDeclared

取得值,指出是否已在組態檔中宣告關聯的組態區段。

IsLocked

取得值,指出是否已鎖定關聯的組態區段。

IsProtected

取得值,指出關聯的組態區段是否屬於受保護。

Name

取得關聯組態區段的名稱。

OverrideMode

取得或設定 OverrideMode 列舉值,這個列舉值會指定子組態檔是否可以覆寫關聯的組態區段。

OverrideModeDefault

取得或設定值,這個值會指定子組態檔覆寫組態區段的預設行為。

OverrideModeEffective

取得組態區段的覆寫行為,這是根據子組態檔是否能鎖定組態區段而定。

ProtectionProvider

取得關聯組態區段的受保護之組態提供者。

RequirePermission

取得值,指出關聯的組態區段是否需要存取權限。

RestartOnExternalChanges

取得或設定值,指出外部組態 Include 檔中的變更是否需要重新啟動應用程式。

SectionName

取得關聯組態區段的名稱。

Type

取得或設定區段類別名稱。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ForceDeclaration()

強制關聯的組態區段出現在組態檔中。

ForceDeclaration(Boolean)

強制關聯的組態區段出現在組態檔中,或是從組態檔中移除現有的區段。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetParentSection()

取得組態區段,其中包含與這個物件有關聯的組態區段。

GetRawXml()

傳回 XML 節點物件,其表示關聯的組態區段物件。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ProtectSection(String)

標示將保護的組態區段。

RevertToParent()

讓關聯的組態區段從父區段繼承其所有的值。

SetRawXml(String)

將物件設定為組態檔內關聯組態區段之 XML 表示。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
UnprotectSection()

從關聯的組態區段移除受保護的組態加密。

適用於

另請參閱