ReflectionPermission.Flags 属性

定义

获取或设置允许用于当前权限的反射类型。

public:
 property System::Security::Permissions::ReflectionPermissionFlag Flags { System::Security::Permissions::ReflectionPermissionFlag get(); void set(System::Security::Permissions::ReflectionPermissionFlag value); };
public System.Security.Permissions.ReflectionPermissionFlag Flags { get; set; }
member this.Flags : System.Security.Permissions.ReflectionPermissionFlag with get, set
Public Property Flags As ReflectionPermissionFlag

属性值

当前权限的设置标志。

例外

尝试将此属性设置为无效值。 有关有效值,请参阅 ReflectionPermissionFlag

示例

下面的代码示例演示如何使用 Flags 属性。 此示例是为 类提供的更大示例的 ReflectionPermission 一部分。

private static void IsSubsetOfDemo()
{
    ReflectionPermission memberAccessPerm = new ReflectionPermission(ReflectionPermissionFlag.MemberAccess);
    ReflectionPermission restrictedMemberAccessPerm = new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess);

    if (restrictedMemberAccessPerm.IsSubsetOf(memberAccessPerm))
    {
        Console.WriteLine(restrictedMemberAccessPerm.Flags + " is a subset of " +
            memberAccessPerm.Flags);
    }
    else
    {
        Console.WriteLine(restrictedMemberAccessPerm.Flags + " is not a subset of " +
            memberAccessPerm.Flags);
    }
}
Private Shared Sub IsSubsetOfDemo()

    Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
    Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)
    If restrictedMemberAccessPerm.IsSubsetOf(memberAccessPerm) Then
        Console.WriteLine(restrictedMemberAccessPerm.Flags + " is a subset of " + memberAccessPerm.Flags)
    Else
        Console.WriteLine(restrictedMemberAccessPerm.Flags.ToString() + _
        " is not a subset of " + memberAccessPerm.Flags.ToString())
    End If

End Sub

适用于