ElementInformation Class
 

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

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

Inheritance Hierarchy
SystemObject
  System.ConfigurationElementInformation

Syntax
public sealed class ElementInformation
public ref class ElementInformation sealed 
[<Sealed>]
type ElementInformation = class end
Public NotInheritable Class ElementInformation
Properties
NameDescription
System_CAPS_pubproperty

Gets the errors for the associated element and subelements

System_CAPS_pubproperty

Gets a value indicating whether the associated ConfigurationElement object is a ConfigurationElementCollection collection.

System_CAPS_pubproperty

Gets a value that indicates whether the associated ConfigurationElement object cannot be modified.

System_CAPS_pubproperty

Gets a value indicating whether the associated ConfigurationElement object is in the configuration file.

System_CAPS_pubproperty

Gets the line number in the configuration file where the associated ConfigurationElement object is defined.

System_CAPS_pubproperty

Gets a PropertyInformationCollection collection of the properties in the associated ConfigurationElement object.

System_CAPS_pubproperty

Gets the source file where the associated ConfigurationElement object originated.

System_CAPS_pubproperty

Gets the type of the associated ConfigurationElement object.

System_CAPS_pubproperty

Gets the object used to validate the associated ConfigurationElement object.

Methods
NameDescription
System_CAPS_pubmethod Equals

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethod GetHashCode

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

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.

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>
Version Information
.NET Framework
Available since 2.0
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.

Return to top