ElementInformation Класс
Определение
Содержит метаинформацию об индивидуальном элементе в пределах конфигурации.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
- Наследование
-
ElementInformation
Примеры
В следующем примере показано, как получить 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 |
Возвращает ошибки для связанного элемента и вложенных элементов.Gets the errors for the associated element and subelements. |
IsCollection |
Возвращает значение, указывающее, является ли связанный объект ConfigurationElement коллекцией ConfigurationElementCollection.Gets a value indicating whether the associated ConfigurationElement object is a ConfigurationElementCollection collection. |
IsLocked |
Возвращает значение, определяющее, можно ли изменять связанный объект ConfigurationElement.Gets a value that indicates whether the associated ConfigurationElement object cannot be modified. |
IsPresent |
Возвращает значение, указывающее, находится ли связанный объект ConfigurationElement в файле конфигурации.Gets a value indicating whether the associated ConfigurationElement object is in the configuration file. |
LineNumber |
Возвращает номер строки в файле конфигурации, в котором определен связанный объект ConfigurationElement.Gets the line number in the configuration file where the associated ConfigurationElement object is defined. |
Properties |
Возвращает коллекцию свойств PropertyInformationCollection в связанном объекте ConfigurationElement.Gets a PropertyInformationCollection collection of the properties in the associated ConfigurationElement object. |
Source |
Возвращает исходный файл, в котором порожден связанный объект ConfigurationElement.Gets the source file where the associated ConfigurationElement object originated. |
Type |
Возвращает тип связанного объекта ConfigurationElement.Gets the type of the associated ConfigurationElement object. |
Validator |
Возвращает объект, использовавшийся для проверки связанного объекта ConfigurationElement.Gets the object used to validate the associated ConfigurationElement object. |
Методы
Equals(Object) |
Определяет, равен ли указанный объект текущему объекту.Determines whether the specified object is equal to the current object. (Унаследовано от Object) |
GetHashCode() |
Служит хэш-функцией по умолчанию.Serves as the default hash function. (Унаследовано от Object) |
GetType() |
Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance. (Унаследовано от Object) |
MemberwiseClone() |
Создает неполную копию текущего объекта Object.Creates a shallow copy of the current Object. (Унаследовано от Object) |
ToString() |
Возвращает строку, представляющую текущий объект.Returns a string that represents the current object. (Унаследовано от Object) |