SectionInformation 类

定义

包含有关配置层次结构中单个节的元数据。 此类不能被继承。

public ref class SectionInformation sealed
public sealed class SectionInformation
type SectionInformation = class
Public NotInheritable Class SectionInformation
继承
SectionInformation

示例

以下示例演示如何获取与 SectionInformation 对象关联的 ConfigurationSection 元数据。

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

以下示例是上一个示例使用的配置文件的摘录。

<?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 包含有关配置层次结构中单个节的元数据。 可以使用此对象来验证和更改单个节的属性。

属性

AllowDefinition

获取或设置一个值,指示配置文件层次结构中可以定义关联配置节的位置。

AllowExeDefinition

获取或设置一个值,指示配置文件层次结构中可以声明关联配置节的位置。

AllowLocation

获取或设置一个值,指示配置节是否允许 location 特性。

AllowOverride

获取或设置一个值,指示较低级别配置文件是否可以重写关联的配置节。

ConfigSource

获取或设置包含文件的名称,关联配置节在其中定义(如果存在这样一个文件)。

ConfigurationBuilder

获取此配置节的 ConfigurationBuilder 对象。

ForceSave

获取或设置一个值,指示是否将保存关联的配置节(即使它未被修改)。

InheritInChildApplications

获取或设置一个值,该值指示在关联配置节中指定的设置是否由驻留在相关应用程序子目录中的应用程序继承。

IsDeclarationRequired

获取一个值,该值指示是否必须在配置文件中声明该配置节。

IsDeclared

获取一个值,指示是否已在配置文件中声明了关联的配置节。

IsLocked

获取一个值,指示关联的配置节是否被锁定。

IsProtected

获取一个值,指示关联的配置节是否受保护。

Name

获取关联配置节的名称。

OverrideMode

获取或设置 OverrideMode 枚举值,该枚举值指定子配置文件是否可以重写关联的配置节。

OverrideModeDefault

获取或设置一个值,该值指定子配置文件对配置节的默认重写行为。

OverrideModeEffective

获取配置节的重写行为,而该行为反过来基于子配置文件是否可锁定该配置节。

ProtectionProvider

获取关联配置节的受保护的配置提供程序。

RequirePermission

获取一个值,指示关联的配置节是否需要访问权限。

RestartOnExternalChanges

获取或设置一个值,指定对外部配置包含文件进行更改后是否需要重新启动应用程序。

SectionName

获取关联配置节的名称。

Type

获取或设置该节的类名称。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
ForceDeclaration()

强制关联的配置节出现在配置文件中。

ForceDeclaration(Boolean)

强制关联的配置节出现在配置文件中,或者从配置文件中移除现有节。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetParentSection()

获取配置节,其中包含与此对象关联的配置节。

GetRawXml()

返回一个 XML 节点对象,表示关联的配置节对象。

GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ProtectSection(String)

标记用于保护的配置节。

RevertToParent()

导致关联的配置节从其父节继承所有值。

SetRawXml(String)

在配置文件内,将该对象设置为关联配置节的 XML 表示形式。

ToString()

返回表示当前对象的字符串。

(继承自 Object)
UnprotectSection()

从关联的配置节中删除受保护的配置加密。

适用于

另请参阅