Export (0) Print
Expand All

ReflectionPermission.Flags Property

Gets or sets the type of reflection allowed for the current permission.

[Visual Basic]
Public Property Flags As ReflectionPermissionFlag
[C#]
public ReflectionPermissionFlag Flags {get; set;}
[C++]
public: __property ReflectionPermissionFlag get_Flags();
public: __property void set_Flags(ReflectionPermissionFlag);
[JScript]
public function get Flags() : ReflectionPermissionFlag;
public function set Flags(ReflectionPermissionFlag);

Property Value

The set flags for the current permission.

Exceptions

Exception Type Condition
ArgumentException An attempt is made to set this property to an invalid value. See ReflectionPermissionFlag for the valid values.

Example

[Visual Basic] 
' IsSubsetOf determines whether the current permission is a subset of the specified permission.
Private Function IsSubsetOfDemo() As Boolean
    Dim returnValue As Boolean = True
    Dim reflection1, reflection2 As ReflectionPermissionFlag
    Dim reflectionPerm1, reflectionPerm2 As ReflectionPermission
    Dim reflectionGen1 As New ReflectionGenerator()
    Dim reflectionGen2 As New ReflectionGenerator()
    reflectionGen1.ResetIndex()
    While reflectionGen1.CreateReflection(reflectionPerm1, reflection1)
        If reflectionPerm1 Is Nothing Then
            GoTo ContinueWhile1
        End If
        reflectionGen2.ResetIndex()
        Console.WriteLine("********************************************************" & ControlChars.Lf)

        While reflectionGen2.CreateReflection(reflectionPerm2, reflection2)
            If reflectionPerm2 Is Nothing Then
                GoTo ContinueWhile2
            End If
            Try
                If reflectionPerm1.IsSubsetOf(reflectionPerm2) Then
                    Console.WriteLine((reflectionPerm1.Flags.ToString() & " is a subset of " _
                    & reflectionPerm2.Flags.ToString()))
                Else
                    Console.WriteLine((reflectionPerm1.Flags.ToString() & " is not a subset of " _
                    & reflectionPerm2.Flags.ToString()))
                End If
            Catch e As Exception
                Console.WriteLine(("An exception was thrown for subset :" & reflectionPerm1.ToString() _
                & ControlChars.Lf & reflectionPerm2.ToString() & ControlChars.Lf & e.ToString()))
                returnValue = False
            End Try
ContinueWhile2:
        End While
ContinueWhile1:
    End While
    Return returnValue
End Function 'IsSubsetOfDemo


[C#] 
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private bool IsSubsetOfDemo()
{
    bool returnValue = true;
    ReflectionPermissionFlag reflection1,reflection2;
    ReflectionPermission reflectionPerm1,reflectionPerm2;
    ReflectionGenerator reflectionGen1 = new ReflectionGenerator();
    ReflectionGenerator reflectionGen2 = new ReflectionGenerator();
    reflectionGen1.ResetIndex();
    while(reflectionGen1.CreateReflection(out reflectionPerm1, out reflection1)) 
    {
        if(reflectionPerm1 == null) continue;
        reflectionGen2.ResetIndex();
        Console.WriteLine("********************************************************\n");

        while(reflectionGen2.CreateReflection(out reflectionPerm2, out reflection2)) 
        {
            if(reflectionPerm2 == null) continue;
            try
            {            
                if (reflectionPerm1.IsSubsetOf(reflectionPerm2))
                {
                    Console.WriteLine(reflectionPerm1.Flags + " is a subset of " + 
                        reflectionPerm2.Flags);
                }
                else
                {
                    Console.WriteLine(reflectionPerm1.Flags + " is not a subset of " + 
                        reflectionPerm2.Flags);
                }
            }
            catch(Exception e) 
            {
                Console.WriteLine("An exception was thrown for subset :" + reflectionPerm1 + "\n" + 
                    reflectionPerm2 +"\n" + e);
                returnValue=false;
            }
        }
    }
    return returnValue;
}

[C++] 
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private:
bool IsSubsetOfDemo() {
   bool returnValue = true;
   ReflectionPermissionFlag reflection1, reflection2;
   ReflectionPermission* reflectionPerm1, *reflectionPerm2;
   ReflectionGenerator* reflectionGen1 = new ReflectionGenerator();
   ReflectionGenerator* reflectionGen2 = new ReflectionGenerator();
   reflectionGen1->ResetIndex();
   while(reflectionGen1->CreateReflection(&reflectionPerm1, &reflection1)) {
      if (reflectionPerm1 == 0) continue;
      reflectionGen2->ResetIndex();
      Console::WriteLine(S"********************************************************\n");

      while(reflectionGen2->CreateReflection(&reflectionPerm2, &reflection2)) {
         if (reflectionPerm2 == 0) continue;
         try {
            if (reflectionPerm1->IsSubsetOf(reflectionPerm2)) {
               Console::WriteLine(S"{0} is a subset of {1}",
                  __box(reflectionPerm1->Flags), __box(reflectionPerm2->Flags));
            } else {
               Console::WriteLine(S"{0} is not a subset of {1}",
                  __box(reflectionPerm1->Flags), __box(reflectionPerm2->Flags));
            }
         } catch (Exception* e) {
            Console::WriteLine(S"An exception was thrown for subset : {0}\n{1}\n{2}",
               reflectionPerm1, reflectionPerm2, e);
            returnValue=false;
         }
      }
   }
   return returnValue;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

ReflectionPermission Class | ReflectionPermission Members | System.Security.Permissions Namespace

Show:
© 2014 Microsoft