DataProtectionPermission.IsSubsetOf(IPermission) 方法

定义

确定当前权限是否为指定权限的子集。

public:
 override bool IsSubsetOf(System::Security::IPermission ^ target);
public override bool IsSubsetOf (System.Security.IPermission target);
override this.IsSubsetOf : System.Security.IPermission -> bool
Public Overrides Function IsSubsetOf (target As IPermission) As Boolean

参数

target
IPermission

将要测试子集关系的权限。 此权限必须与当前权限属于同一类型。

返回

Boolean

如果当前权限是指定权限的子集,则为 true;否则为 false

例外

target 不是 null,并且未指定同一类型的权限为当前权限。

示例

下面的代码示例演示了该方法 IsSubsetOf 的使用。 此代码示例是为类提供的大型示例的 DataProtectionPermission 一部分。

备注

代码示例旨在显示方法的行为,而不是演示其用法。 一般情况下,安全基础结构使用权限类的方法;它们通常不用于应用程序。

bool rc = sp2->IsSubsetOf( sp3 );
Console::WriteLine( "Is the permission with all flags set (AllFlags) "
"a subset of \n \tthe permission with an Unrestricted "
"permission state? {0}", (rc ? (String^)"Yes" : "No") );
rc = sp1->IsSubsetOf( sp2 );
Console::WriteLine( "Is the permission with ProtectData access a "
"subset of the permission with \n"
"\tAllFlags set? {0}", (rc ? (String^)"Yes" : "No") );
bool rc = sp2.IsSubsetOf(sp3);
Console.WriteLine("Is the permission with all flags set (AllFlags) " +
    "a subset of \n \tthe permission with an Unrestricted " +
    "permission state? " + (rc ? "Yes" : "No"));
rc = sp1.IsSubsetOf(sp2);
Console.WriteLine("Is the permission with ProtectData access a " +
    "subset of the permission with \n" + "\tAllFlags set? " +
    (rc ? "Yes" : "No"));
Dim rc As Boolean = sp2.IsSubsetOf(sp3)
Console.WriteLine("Is the permission with all flags set (AllFlags) " + "a subset of " + vbLf + " " + vbTab + "the permission with an Unrestricted " + "permission state? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
rc = sp1.IsSubsetOf(sp2)
Console.WriteLine("Is the permission with ProtectData access a " + "subset of the permission with " + vbLf + vbTab + "AllFlags set? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements

注解

如果当前权限指定了一组完全包含在指定权限中的操作,则当前权限是指定权限的子集。 例如,访问权限 ProtectData 的子集是访问权限的 AllFlags 子集。

适用于