ElementInformation ElementInformation ElementInformation ElementInformation Class

定義

包含組態內與個別項目有關的中繼資訊。Contains meta-information about an individual element within the configuration. 這個類別無法被繼承。This class cannot be inherited.

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

範例

下列範例顯示如何取得ElementInformation ConfigurationElement與物件相關聯的。The following example shows how to get the ElementInformation associated with a ConfigurationElement object.

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     

下列摘錄顯示先前程式碼範例所使用的設定。The following excerpt shows the configuration used by the previous code example.

<?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物件包含有關設定內個別專案的中繼資料資訊。The ElementInformation object contains meta-information about an individual element within the configuration. 驗證和變更個別元素的屬性時, 可以使用這個物件。This object can be used when validating and changing the properties of an individual element.

屬性

Errors Errors Errors Errors

取得關聯項目和子項目的錯誤。Gets the errors for the associated element and subelements

IsCollection IsCollection IsCollection IsCollection

取得值,指出關聯的 ConfigurationElement 物件是否在 ConfigurationElementCollection 集合中。Gets a value indicating whether the associated ConfigurationElement object is a ConfigurationElementCollection collection.

IsLocked IsLocked IsLocked IsLocked

取得值,指出是否無法修改關聯的 ConfigurationElement 物件。Gets a value that indicates whether the associated ConfigurationElement object cannot be modified.

IsPresent IsPresent IsPresent IsPresent

取得值,指出關聯的 ConfigurationElement 物件是否在組態檔中。Gets a value indicating whether the associated ConfigurationElement object is in the configuration file.

LineNumber LineNumber LineNumber LineNumber

取得在組態檔中定義關聯 ConfigurationElement 物件的行號。Gets the line number in the configuration file where the associated ConfigurationElement object is defined.

Properties Properties Properties Properties

取得關聯 PropertyInformationCollection 物件中屬性的 ConfigurationElement 集合。Gets a PropertyInformationCollection collection of the properties in the associated ConfigurationElement object.

Source Source Source Source

取得關聯 ConfigurationElement 物件所源自的原始程式檔。Gets the source file where the associated ConfigurationElement object originated.

Type Type Type Type

取得相關聯 ConfigurationElement 物件的型別。Gets the type of the associated ConfigurationElement object.

Validator Validator Validator Validator

取得用來驗證關聯 ConfigurationElement 物件的物件。Gets the object used to validate the associated ConfigurationElement object.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱