SectionInformation SectionInformation SectionInformation SectionInformation Class

定义

包含有关配置层次结构中单个节的元数据。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
继承
SectionInformationSectionInformationSectionInformationSectionInformation

示例

下面的示例演示如何获取SectionInformation ConfigurationSection与对象关联的元数据。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>  

注解

SectionInformation对象包含有关配置层次结构中单个部分的元数据。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.

属性

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

获取或设置一个值,指示配置节是否允许 location 特性。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

获取此配置节的 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

获取或设置 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.

方法

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

返回一个 XML 节点对象,表示关联的配置节对象。Returns an XML node object that represents the associated configuration-section object.

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

获取当前实例的 TypeGets the Type of the current instance.

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

创建当前 Object 的浅表副本。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)

在配置文件内,将该对象设置为关联配置节的 XML 表示形式。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.

适用于

另请参阅