ReflectionPermission.Flags 屬性

定義

取得或設定目前權限允許的反映類型。Gets or sets the type of reflection allowed for the current permission.

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

目前權限的設定旗標。The set flags for the current permission.

例外狀況

嘗試將這個屬性設定為無效的值。An attempt is made to set this property to an invalid value. 如需有效值,請參閱 ReflectionPermissionFlagSee ReflectionPermissionFlag for the valid values.

範例

下列程式碼範例示範如何使用 Flags 屬性。The following code example shows the use of the Flags property. 這個範例是針對類別提供之較大範例的一部分 ReflectionPermissionThis example is part of a larger example provided for the ReflectionPermission class.

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

適用於