DataProtectionPermission.IsSubsetOf(IPermission) Método

Definição

Determina se a permissão atual é um subconjunto da permissão especificada.Determines whether the current permission is a subset of the specified permission.

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

Parâmetros

target
IPermission

Uma permissão para testar a relação de subconjunto.A permission to test for the subset relationship. Essa permissão deve ser do mesmo tipo que a permissão atual.This permission must be the same type as the current permission.

Retornos

Boolean

true se a permissão atual for um subconjunto da permissão especificada; caso contrário, false.true if the current permission is a subset of the specified permission; otherwise, false.

Exceções

target não é null e não especifica uma permissão do mesmo tipo da permissão atual.target is not null and does not specify a permission of the same type as the current permission.

Exemplos

O exemplo de código a seguir mostra o uso do IsSubsetOf método.The following code example shows the use of the IsSubsetOf method. Este exemplo de código faz parte de um exemplo maior fornecido para a DataProtectionPermission classe.This code example is part of a larger example provided for the DataProtectionPermission class.

Observação

O exemplo de código destina-se a mostrar o comportamento do método, não para demonstrar seu uso.The code example is intended to show the behavior of the method, not to demonstrate its use. Em geral, os métodos de classes de permissão são usados pela infraestrutura de segurança; Normalmente, eles não são usados em aplicativos.In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.

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

Comentários

A permissão atual é um subconjunto da permissão especificada se a permissão atual especifica um conjunto de operações que está totalmente contido na permissão especificada.The current permission is a subset of the specified permission if the current permission specifies a set of operations that is wholly contained in the specified permission. Por exemplo, uma permissão para ProtectData acesso é um subconjunto de uma permissão para AllFlags acesso.For example, a permission for ProtectData access is a subset of a permission for AllFlags access.

Aplica-se a