SecurityAttribute.Unrestricted问题问题、SecurityAttribute、Unrestricted

2023-09-03 04:34:47 作者:眉目清俊

我很困惑这个属性,这里提到的,http://msdn.microsoft.com/en-us/library/system.security.permissions.securityattribute.unrestricted.aspx我们可以给它完整或不完整的。

I am confused about this property, as mentioned here, http://msdn.microsoft.com/en-us/library/system.security.permissions.securityattribute.unrestricted.aspx we could give it full or non-full.

我的困惑是在一个简单的理解权限,应该只有两个状态 - 理所当然的,不批准,哪些呢个全和非全均

My confusion is for permission in a straightforward understanding, there should be only two status -- granted and not-granted, what does th full and non-full mean?

在此先感谢, 乔治

推荐答案

我有previously用在经典的方式无限制属性:

I have previously used the Unrestricted attribute in the classic way:

下面code是一个请求,说明程序集必须以功能不受限制地访问文件系统。

The following code is a request stating that an assembly must have unrestricted access to the file system in order to function.

using System.Security.Permissions;
// Indicates that FileIOPermission is required to run this assembly.
[assembly:FileIOPermission(SecurityAction.RequestMinimum, Unrestricted=true)]
public class FileManager
{
// Insert code to add and delete files.
}

在这方面不受限=假意味着不nessessarily必需的,要执行的方法。文件访问

in this context Unrestricted=false would mean file access is not nessessarily required, for the method to execute.

相对于'oppisite'这需要,为了使执行,文件访问不能授予方法

as opposed to the 'oppisite' which would require that in order for the method to execute, file access must not be granted.

在大多数情况下SecurityAction(无限制=真||假的)可以dynamicaly创建,第一种情况下,通常会更有意义。

In most cases where the SecurityAction (Unrestricted=true||false) may be created dynamicaly, the first case usually makes more sense.