SectionInformation SectionInformation SectionInformation SectionInformation Class

Definition

Contains metadata about an individual section within the configuration hierarchy. This class cannot be inherited.

public ref class SectionInformation sealed
public sealed class SectionInformation
type SectionInformation = class
Public NotInheritable Class SectionInformation
Inheritance
SectionInformationSectionInformationSectionInformationSectionInformation

Examples

The following example shows how to get the SectionInformation metadata that is associated with a ConfigurationSection object.

static public SectionInformation 
    GetSectionInformation()
{

    // Get the current configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    // Get the section.
    UrlsSection section =
        (UrlsSection)config.GetSection("MyUrls");

    
    SectionInformation sInfo = 
        section.SectionInformation;

    return sInfo;

}
Public Shared Function GetSectionInformation() _
As SectionInformation

    ' 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)

    Dim sInfo As SectionInformation = _
    section.SectionInformation

    Return sInfo

End Function 'GetSectionInformation
 

The following example is an excerpt of the configuration file that is used by the previous 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>  

Remarks

The SectionInformation object contains the metadata about an individual section within the configuration hierarchy. This object can be used in order to validate and change the properties of an individual section.

Properties

AllowDefinition AllowDefinition AllowDefinition AllowDefinition

Gets or sets a value that indicates where in the configuration file hierarchy the associated configuration section can be defined.

AllowExeDefinition AllowExeDefinition AllowExeDefinition AllowExeDefinition

Gets or sets a value that indicates where in the configuration file hierarchy the associated configuration section can be declared.

AllowLocation AllowLocation AllowLocation AllowLocation

Gets or sets a value that indicates whether the configuration section allows the location attribute.

AllowOverride AllowOverride AllowOverride AllowOverride

Gets or sets a value that indicates whether the associated configuration section can be overridden by lower-level configuration files.

ConfigSource ConfigSource ConfigSource ConfigSource

Gets or sets the name of the include file in which the associated configuration section is defined, if such a file exists.

ConfigurationBuilder ConfigurationBuilder ConfigurationBuilder ConfigurationBuilder

Gets the ConfigurationBuilder object for this configuration section.

ForceSave ForceSave ForceSave ForceSave

Gets or sets a value that indicates whether the associated configuration section will be saved even if it has not been modified.

InheritInChildApplications InheritInChildApplications InheritInChildApplications InheritInChildApplications

Gets or sets a value that indicates whether the settings that are specified in the associated configuration section are inherited by applications that reside in a subdirectory of the relevant application.

IsDeclarationRequired IsDeclarationRequired IsDeclarationRequired IsDeclarationRequired

Gets a value that indicates whether the configuration section must be declared in the configuration file.

IsDeclared IsDeclared IsDeclared IsDeclared

Gets a value that indicates whether the associated configuration section is declared in the configuration file.

IsLocked IsLocked IsLocked IsLocked

Gets a value that indicates whether the associated configuration section is locked.

IsProtected IsProtected IsProtected IsProtected

Gets a value that indicates whether the associated configuration section is protected.

Name Name Name Name

Gets the name of the associated configuration section.

OverrideMode OverrideMode OverrideMode OverrideMode

Gets or sets the OverrideMode enumeration value that specifies whether the associated configuration section can be overridden by child configuration files.

OverrideModeDefault OverrideModeDefault OverrideModeDefault OverrideModeDefault

Gets or sets a value that specifies the default override behavior of a configuration section by child configuration files.

OverrideModeEffective OverrideModeEffective OverrideModeEffective OverrideModeEffective

Gets the override behavior of a configuration section that is in turn based on whether child configuration files can lock the configuration section.

ProtectionProvider ProtectionProvider ProtectionProvider ProtectionProvider

Gets the protected configuration provider for the associated configuration section.

RequirePermission RequirePermission RequirePermission RequirePermission

Gets a value that indicates whether the associated configuration section requires access permissions.

RestartOnExternalChanges RestartOnExternalChanges RestartOnExternalChanges RestartOnExternalChanges

Gets or sets a value that specifies whether a change in an external configuration include file requires an application restart.

SectionName SectionName SectionName SectionName

Gets the name of the associated configuration section.

Type Type Type Type

Gets or sets the section class name.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ForceDeclaration() ForceDeclaration() ForceDeclaration() ForceDeclaration()

Forces the associated configuration section to appear in the configuration file.

ForceDeclaration(Boolean) ForceDeclaration(Boolean) ForceDeclaration(Boolean) ForceDeclaration(Boolean)

Forces the associated configuration section to appear in the configuration file, or removes an existing section from the configuration file.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetParentSection() GetParentSection() GetParentSection() GetParentSection()

Gets the configuration section that contains the configuration section associated with this object.

GetRawXml() GetRawXml() GetRawXml() GetRawXml()

Returns an XML node object that represents the associated configuration-section object.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ProtectSection(String) ProtectSection(String) ProtectSection(String) ProtectSection(String)

Marks a configuration section for protection.

RevertToParent() RevertToParent() RevertToParent() RevertToParent()

Causes the associated configuration section to inherit all its values from the parent section.

SetRawXml(String) SetRawXml(String) SetRawXml(String) SetRawXml(String)

Sets the object to an XML representation of the associated configuration section within the configuration file.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
UnprotectSection() UnprotectSection() UnprotectSection() UnprotectSection()

Removes the protected configuration encryption from the associated configuration section.

Applies to

See Also