StrongNameIdentityPermission.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 方法的结果,而不是如何使用 方法。 此示例是为 类提供的更大示例的一 StrongNameIdentityPermission 部分。 此示例的最佳用途是生成并执行整个示例,并查看其输出。

注意

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

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

注解

如果当前权限指定由指定权限完全包含的一组操作,则当前权限是指定权限的子集。 例如,其他属性相等,包含 Name 通配符表达式 MyCompany.MyDepartment.* 的属性的标识被标识为具有属性 MyCompany.MyDepartment.MyFile 的标识 Name 子集。

适用于