ElementInformation 類別

定義

包含組態內與個別項目有關的中繼資訊。 此類別無法獲得繼承。

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

範例

下列範例示範如何取得 ElementInformationConfigurationElement 物件相關聯的 。

static public ElementInformation
    GetElementInformation()
{

    // Get the current configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    // Get the section.
    UrlsSection section =
        (UrlsSection)config.GetSection("MyUrls");

    // Get the element.
    UrlConfigElement url = section.Simple;

    ElementInformation eInfo =
        url.ElementInformation;

    return eInfo;
}
Public Shared Function GetElementInformation() _
As ElementInformation

    ' 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)

    ' Get the element.
    Dim url As UrlConfigElement = _
    section.Simple

    Dim eInfo As ElementInformation = _
    url.ElementInformation

    Return eInfo

End Function 'GetElementInformation

下列摘錄顯示先前程式代碼範例所使用的組態。

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

備註

ElementInformation物件包含組態中個別元素的中繼資訊。 驗證和變更個別元素的屬性時,可以使用這個物件。

屬性

Errors

取得關聯元素和子元素的錯誤。

IsCollection

取得值,指出關聯的 ConfigurationElement 物件是否在 ConfigurationElementCollection 集合中。

IsLocked

取得值,指出是否無法修改關聯的 ConfigurationElement 物件。

IsPresent

取得值,指出關聯的 ConfigurationElement 物件是否在組態檔中。

LineNumber

取得在組態檔中定義關聯 ConfigurationElement 物件的行號。

Properties

取得關聯 PropertyInformationCollection 物件中屬性的 ConfigurationElement 集合。

Source

取得關聯 ConfigurationElement 物件所源自的原始程式檔。

Type

取得相關聯 ConfigurationElement 物件的型別。

Validator

取得用來驗證關聯 ConfigurationElement 物件的物件。

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱