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 的浅表副本。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)

适用于

另请参阅