Επεξεργασία

Κοινή χρήση μέσω


StrongNameIdentityPermission.IsSubsetOf(IPermission) Method

Definition

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

Parameters

target
IPermission

A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission.

Returns

true if the current permission is a subset of the specified permission; otherwise, false.

Exceptions

The target parameter is not null and is not of the same type as the current permission.

Examples

The following code example shows the results of the use of the IsSubsetOf method, not how to use the method. This example is part of a larger example provided for the StrongNameIdentityPermission class. The best use for this example is to build and execute the entire example, and view its output.

Note

The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.

// 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

Remarks

The current permission is a subset of the specified permission if the current permission specifies a set of operations that is wholly contained by the specified permission. For example, the other properties being equal, an identity with the Name property containing the wildcard expression MyCompany.MyDepartment.* is identified as a subset of an identity with the Name property MyCompany.MyDepartment.MyFile.

Applies to