다음을 통해 공유


ReflectionPermission.IsSubsetOf 메서드

현재 사용 권한이 지정된 사용 권한의 하위 집합인지 여부를 확인합니다.

네임스페이스: System.Security.Permissions
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overrides Function IsSubsetOf ( _
    target As IPermission _
) As Boolean
‘사용 방법
Dim instance As ReflectionPermission
Dim target As IPermission
Dim returnValue As Boolean

returnValue = instance.IsSubsetOf(target)
public override bool IsSubsetOf (
    IPermission target
)
public:
virtual bool IsSubsetOf (
    IPermission^ target
) override
public boolean IsSubsetOf (
    IPermission target
)
public override function IsSubsetOf (
    target : IPermission
) : boolean

매개 변수

  • target
    하위 집합 관계를 테스트할 사용 권한입니다. 이 사용 권한은 현재 사용 권한과 형식이 같아야 합니다.

반환 값

현재 사용 권한이 지정된 사용 권한의 하위 집합이면 true이고, 그렇지 않으면 false입니다.

예외

예외 형식 조건

ArgumentException

target 매개 변수가 Null 참조(Visual Basic의 경우 Nothing)이 아니고 현재 사용 권한과 형식이 다른 경우

설명

현재 사용 권한이 지정된 사용 권한에 완전히 포함된 작업 집합을 지정하는 경우 현재 사용 권한은 지정된 사용 권한의 하위 집합입니다. 예를 들어, C:\example.txt에 대한 액세스를 나타내는 사용 권한은 C:\에 대한 액세스를 나타내는 사용 권한의 하위 집합입니다. 이 메서드가 true를 반환하면 현재 사용 권한은 보호되는 리소스에 대해 지정된 사용 권한과 동일한 액세스 권한을 나타냅니다.

예제

    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(reflection1)
            reflectionPerm1 = New ReflectionPermission(reflection1)
            reflectionGen2.ResetIndex()
            Console.WriteLine("********************************************************" & ControlChars.Lf)
            While reflectionGen2.CreateReflection(reflection2)
                reflectionPerm2 = New ReflectionPermission(reflection2)
                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
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 reflection1))
    {
        reflectionPerm1 = new ReflectionPermission(reflection1);
        reflectionGen2.ResetIndex();
        Console.WriteLine("********************************************************\n");

        while (reflectionGen2.CreateReflection(out reflection2))
        {
            reflectionPerm2 = new ReflectionPermission(reflection2);
            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;
}
bool IsSubsetOfDemo()
{
   bool returnValue = true;
   ReflectionPermissionFlag reflection1;
   ReflectionPermissionFlag reflection2;
   ReflectionPermission^ reflectionPerm1;
   ReflectionPermission^ reflectionPerm2;
   ReflectionGenerator^ reflectionGen1 = gcnew ReflectionGenerator;
   ReflectionGenerator^ reflectionGen2 = gcnew ReflectionGenerator;
   reflectionGen1->ResetIndex();
   while ( reflectionGen1->CreateReflection(  &reflection1 ) )
   {
      reflectionPerm1 = gcnew ReflectionPermission( reflection1 );
      reflectionGen2->ResetIndex();
      Console::WriteLine( "********************************************************\n" );
      while ( reflectionGen2->CreateReflection(  &reflection2 ) )
      {
         reflectionPerm2 = gcnew ReflectionPermission( reflection2 );  
         try
         {
            if ( reflectionPerm1->IsSubsetOf( reflectionPerm2 ) )
            {
               Console::WriteLine( "{0} is a subset of {1}", reflectionPerm1->Flags, reflectionPerm2->Flags );
            }
            else
            {
               Console::WriteLine( "{0} is not a subset of {1}", reflectionPerm1->Flags, reflectionPerm2->Flags );
            }
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( "An exception was thrown for subset : {0}\n{1}\n{2}", reflectionPerm1, reflectionPerm2, e );
            returnValue = false;
         }

      }
   }

   return returnValue;
}
private boolean IsSubsetOfDemo() 
{
    boolean returnValue = true;
    ReflectionPermissionFlag reflection1[] = 
        new ReflectionPermissionFlag[1] ;
    ReflectionPermissionFlag reflection2[] = 
        new ReflectionPermissionFlag[1] ;
    ReflectionPermission reflectionPerm1[] = 
        new ReflectionPermission[1] ;
    ReflectionPermission reflectionPerm2[] = 
        new ReflectionPermission[1];
    ReflectionGenerator reflectionGen1 =  
        new ReflectionGenerator();
    ReflectionGenerator reflectionGen2 =  
        new ReflectionGenerator();
    reflectionGen1.ResetIndex();
    while(reflectionGen1.CreateReflection(reflectionPerm1, reflection1)) {
        if (reflectionPerm1[0] == null) {
            continue ;
        }
        reflectionGen2.ResetIndex();
        Console.WriteLine("***************************************" 
            + "*****************\n");
        
        while(reflectionGen2.CreateReflection(
            reflectionPerm2, reflection2)) {
            if (reflectionPerm2[0] == null) {
                continue ;
            }
            try {
                if ( reflectionPerm1[0].IsSubsetOf(reflectionPerm2[0])) {
                    Console.WriteLine((reflectionPerm1[0].get_Flags() 
                        + " is a subset of " + 
                    reflectionPerm2[0].get_Flags()));
                }
                else {
                    Console.WriteLine((reflectionPerm1[0].get_Flags() 
                        + " is not a subset of " 
                        + reflectionPerm2[0].get_Flags()));
                }
            }
            catch(System.Exception e) {
                Console.WriteLine(("An exception was " 
                    + "thrown for subset :" + reflectionPerm1[0] + "\n" 
                    + reflectionPerm2[0] + "\n" + e));
                returnValue = false;
            }
        }
    }
    return returnValue ;
} //IsSubsetOfDemo

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ReflectionPermission 클래스
ReflectionPermission 멤버
System.Security.Permissions 네임스페이스