.NET Framework Class Library
ElementInformation Class

Contains meta-information about an individual element within the configuration. This class cannot be inherited.

Inheritance Hierarchy
SystemObject
  System.ConfigurationElementInformation

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Syntax
Public NotInheritable Class ElementInformation
public sealed class ElementInformation
public ref class ElementInformation sealed
[<[%$TOPIC/ms134413_en-us_VS_110_2_0_3_0_0%]>]
type ElementInformation =  class end

The ElementInformation type exposes the following members.

Properties
  NameDescription
Public property ErrorsGets the errors for the associated element and subelements
Public property IsCollectionGets a value indicating whether the associated ConfigurationElement object is a ConfigurationElementCollection collection.
Public property IsLockedGets a value that indicates whether the associated ConfigurationElement object cannot be modified.
Public property IsPresentGets a value indicating whether the associated ConfigurationElement object is in the configuration file.
Public property LineNumberGets the line number in the configuration file where the associated ConfigurationElement object is defined.
Public property PropertiesGets a PropertyInformationCollection collection of the properties in the associated ConfigurationElement object.
Public property SourceGets the source file where the associated ConfigurationElement object originated.
Public property TypeGets the type of the associated ConfigurationElement object.
Public property ValidatorGets the object used to validate the associated ConfigurationElement object.
Top
Methods
  NameDescription
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Remarks

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.

Examples

The following example shows how to get the ElementInformation associated with a ConfigurationElement object.

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

}

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>
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.