共用方式為


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

要測試子集關聯性的權限。 這個權限必須與目前權限屬於相同的類型。

傳回

如果目前權限是指定權限的子集,則為 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 的子集。

適用於