ElementInformation Klasa

Definicja

Zawiera metadane dotyczące pojedynczego elementu w konfiguracji. Klasa ta nie może być dziedziczona.

public ref class ElementInformation sealed
public sealed class ElementInformation
type ElementInformation = class
Public NotInheritable Class ElementInformation
Dziedziczenie
ElementInformation

Przykłady

W poniższym przykładzie pokazano, jak uzyskać ElementInformation skojarzenie z obiektem ConfigurationElement .

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

Poniższy fragment przedstawia konfigurację używaną przez poprzedni przykład kodu.

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

Uwagi

Obiekt ElementInformation zawiera metadane dotyczące pojedynczego elementu w konfiguracji. Ten obiekt może być używany podczas walidacji i zmieniania właściwości pojedynczego elementu.

Właściwości

Errors

Pobiera błędy skojarzonego elementu i podelementów.

IsCollection

Pobiera wartość wskazującą, czy skojarzony ConfigurationElement obiekt jest kolekcją ConfigurationElementCollection .

IsLocked

Pobiera wartość wskazującą, czy nie można zmodyfikować skojarzonego ConfigurationElement obiektu.

IsPresent

Pobiera wartość wskazującą, czy skojarzony ConfigurationElement obiekt znajduje się w pliku konfiguracji.

LineNumber

Pobiera numer wiersza w pliku konfiguracji, w którym jest zdefiniowany skojarzony ConfigurationElement obiekt.

Properties

PropertyInformationCollection Pobiera kolekcję właściwości w skojarzonym ConfigurationElement obiekcie.

Source

Pobiera plik źródłowy, z którego pochodzi skojarzony ConfigurationElement obiekt.

Type

Pobiera typ skojarzonego ConfigurationElement obiektu.

Validator

Pobiera obiekt używany do sprawdzania poprawności skojarzonego ConfigurationElement obiektu.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też