ElementInformation Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- Inheritance
-
ElementInformation
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>
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 |
Gets the errors for the associated element and subelements. |
Is |
Gets a value indicating whether the associated ConfigurationElement object is a ConfigurationElementCollection collection. |
Is |
Gets a value that indicates whether the associated ConfigurationElement object cannot be modified. |
Is |
Gets a value indicating whether the associated ConfigurationElement object is in the configuration file. |
Line |
Gets the line number in the configuration file where the associated ConfigurationElement object is defined. |
Properties |
Gets a PropertyInformationCollection collection of the properties in the associated ConfigurationElement object. |
Source |
Gets the source file where the associated ConfigurationElement object originated. |
Type |
Gets the type of the associated ConfigurationElement object. |
Validator |
Gets the object used to validate the associated ConfigurationElement object. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: