StrongNameIdentityPermission.IsSubsetOf(IPermission) Metodo

Definizione

Determina se l'autorizzazione corrente è un subset di quella specificata.

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

Parametri

target
IPermission

Autorizzazione da testare per la relazione del subset. Questa autorizzazione deve essere dello stesso tipo di quella corrente.

Restituisce

true se l'autorizzazione corrente è un subset di quella specificata; in caso contrario, false.

Eccezioni

Il parametro target non è null e non è dello stesso tipo dell'autorizzazione corrente.

Esempio

Nell'esempio di codice seguente vengono illustrati i risultati dell'uso del IsSubsetOf metodo, non come usare il metodo. Questo esempio fa parte di un esempio più grande fornito per la StrongNameIdentityPermission classe. L'uso migliore per questo esempio consiste nel compilare ed eseguire l'intero esempio e visualizzarne l'output.

Nota

L'esempio di codice è destinato a mostrare il comportamento del metodo, non per illustrarne l'uso. In generale, i metodi delle classi di autorizzazione vengono usati dall'infrastruttura di sicurezza; non vengono in genere usati nelle applicazioni.

// IsSubsetOf determines whether the current permission is a subset of the specified permission.
bool IsSubsetOfDemo()
{
    bool returnValue = true;

    StrongNameIdentityPermission^ snIdPerm1;
    StrongNameIdentityPermission^ snIdPerm2;

    snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
    snIdPerm2 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", gcnew Version("1.0.0.0"));

    if (snIdPerm1->IsSubsetOf(snIdPerm2))
    {

        Console::WriteLine("MyCompany.MyDepartment.* is a subset " +
            "of MyCompany.MyDepartment.MyFile \n");
    }
    else
    {
        Console::WriteLine("MyCompany.MyDepartment.*" +
            " is not a subset of MyCompany.MyDepartment.MyFile \n");
    }

    return returnValue;
}
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private bool IsSubsetOfDemo()
{

    bool returnValue = true;

    StrongNameIdentityPermission snIdPerm1, snIdPerm2;

    snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
    snIdPerm2 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", new Version("1.0.0.0"));

    if (snIdPerm1.IsSubsetOf(snIdPerm2))
    {

        Console.WriteLine("MyCompany.MyDepartment.* is a subset " +
        "of MyCompany.MyDepartment.MyFile \n");
    }
    else
    {
        Console.WriteLine("MyCompany.MyDepartment.*" +
        " is not a subset of MyCompany.MyDepartment.MyFile \n");
    }

    return returnValue;
}
' IsSubsetOf determines whether the current permission is a subset of the specified permission.
Private Function IsSubsetOfDemo() As Boolean 
    
    Dim returnValue As Boolean = True
    
    Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
    
    snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
    snIdPerm2 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", New Version("1.0.0.0"))
    
    If snIdPerm1.IsSubsetOf(snIdPerm2) Then
        
        Console.WriteLine("MyCompany.MyDepartment.* is a subset " + "of MyCompany.MyDepartment.MyFile " + vbLf)
    Else
        Console.WriteLine("MyCompany.MyDepartment.*" + " is not a subset of MyCompany.MyDepartment.MyFile " + vbLf)
    End If
    
    Return returnValue

End Function 'IsSubsetOfDemo

Commenti

L'autorizzazione corrente è un subset dell'autorizzazione specificata se l'autorizzazione corrente specifica un set di operazioni interamente contenuto dall'autorizzazione specificata. Ad esempio, le altre proprietà uguali, un'identità con la proprietà contenente l'espressione Name jolly MyCompany.MyDepartment.* viene identificata come subset di un'identità con la Name proprietà MyCompany.MyDepartment.MyFile.

Si applica a