ConfigurationPermission 类

定义

注意

Code Access Security is not supported or honored by the runtime.

提供允许方法或类访问配置文件的权限结构。Provides a permission structure that allows methods or classes to access configuration files.

public ref class ConfigurationPermission sealed : System::Security::CodeAccessPermission, System::Security::Permissions::IUnrestrictedPermission
public sealed class ConfigurationPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class ConfigurationPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
[System.Serializable]
public sealed class ConfigurationPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
type ConfigurationPermission = class
    inherit CodeAccessPermission
    interface IUnrestrictedPermission
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ConfigurationPermission = class
    inherit CodeAccessPermission
    interface IUnrestrictedPermission
[<System.Serializable>]
type ConfigurationPermission = class
    inherit CodeAccessPermission
    interface IUnrestrictedPermission
Public NotInheritable Class ConfigurationPermission
Inherits CodeAccessPermission
Implements IUnrestrictedPermission
继承
ConfigurationPermission
属性
实现

注解

ConfigurationPermission类提供允许方法或类访问配置文件的权限结构。The ConfigurationPermission class provides a permission structure that allows methods or classes to access configuration files. 此外,还 ConfigurationPermission 提供了使用和等方法解析多个权限值的方法 Union IntersectAlso, ConfigurationPermission provides ways to resolve multiple permissions values through such methods as Union and Intersect.

构造函数

ConfigurationPermission(PermissionState)

初始化 ConfigurationPermission 类的新实例。Initializes a new instance of the ConfigurationPermission class.

方法

Assert()

声明调用代码能够通过调用此方法的代码,访问受权限请求保护的资源,即使未对堆栈中处于较高位置的调用方授予访问该资源的权限。Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. 使用 Assert() 会引起安全问题。Using Assert() can create security issues.

(继承自 CodeAccessPermission)
Copy()

返回具有相同权限级别的新的 ConfigurationPermission 对象。Returns a new ConfigurationPermission object with the same permission level.

Demand()

如果未对调用堆栈中处于较高位置的所有调用方授予当前实例所指定的权限,则在运行时强制 SecurityExceptionForces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.

(继承自 CodeAccessPermission)
Deny()
已过时。
已过时。

防止处于调用堆栈较高位置的调用函数使用可以调用此方法来访问当前实例指定资源的代码。Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance.

(继承自 CodeAccessPermission)
Equals(Object)

确定指定的 CodeAccessPermission 对象是否等于当前的 CodeAccessPermissionDetermines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission.

(继承自 CodeAccessPermission)
FromXml(SecurityElement)

从 XML 读取权限状态值。Reads the value of the permission state from XML.

GetHashCode()

获取 CodeAccessPermission 对象的哈希代码,此代码适合在哈希算法和数据结构(例如哈希表)中使用。Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table.

(继承自 CodeAccessPermission)
GetType()

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

(继承自 Object)
Intersect(IPermission)

返回 ConfigurationPermission 对象与实现 IPermission 接口的给定对象的逻辑交集。Returns the logical intersection between the ConfigurationPermission object and a given object that implements the IPermission interface.

IsSubsetOf(IPermission)

ConfigurationPermission 对象与实现 IPermission 接口的对象进行比较。Compares the ConfigurationPermission object with an object implementing the IPermission interface.

IsUnrestricted()

指示 ConfigurationPermission 对象的权限状态是否为 Unrestricted 枚举的 PermissionState 值。Indicates whether the permission state for the ConfigurationPermission object is the Unrestricted value of the PermissionState enumeration.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
PermitOnly()

防止处于调用堆栈较高位置的调用函数使用此代码,此代码将调用此方法来访问除当前实例指定的资源以外的所有资源。Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.

(继承自 CodeAccessPermission)
ToString()

创建并返回当前权限对象的字符串表示形式。Creates and returns a string representation of the current permission object.

(继承自 CodeAccessPermission)
ToXml()

返回一个 SecurityElement 对象,其特性值取决于当前 ConfigurationPermission 对象。Returns a SecurityElement object with attribute values based on the current ConfigurationPermission object.

Union(IPermission)

返回 ConfigurationPermission 对象与实现 IPermission 接口的对象的逻辑并集。Returns the logical union of the ConfigurationPermission object and an object that implements the IPermission interface.

显式接口实现

IPermission.Demand()

如果不满足安全要求,则会在运行时引发 SecurityExceptionThrows a SecurityException at run time if the security requirement is not met.

(继承自 CodeAccessPermission)
IStackWalk.Assert()

断言调用代码可以访问当前权限对象所标识的资源,即使尚未对堆栈中的高级调用方授予访问该资源的权限。Asserts that the calling code can access the resource identified by the current permission object, even if callers higher in the stack have not been granted permission to access the resource.

(继承自 CodeAccessPermission)
IStackWalk.Demand()

在运行时确定调用堆栈中的所有调用方是否已被授予当前权限对象所指定的权限。Determines at run time whether all callers in the call stack have been granted the permission specified by the current permission object.

(继承自 CodeAccessPermission)
IStackWalk.Deny()

将导致通过调用代码传递的当前对象的每个 Demand() 失败。Causes every Demand() for the current object that passes through the calling code to fail.

(继承自 CodeAccessPermission)
IStackWalk.PermitOnly()

导致所有对象的每个 Demand()(除了通过调用代码的当前那个)失败,即使调用堆栈中较高级别的代码已被授予访问其他资源的权限也是如此。Causes every Demand() for all objects except the current one that pass through the calling code to fail, even if code higher in the call stack has been granted permission to access other resources.

(继承自 CodeAccessPermission)

适用于

另请参阅