CodeAccessPermission.IsSubsetOf(IPermission) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 구현할 때 현재 권한이 지정된 권한의 하위 집합인지 여부를 결정합니다.
public:
abstract bool IsSubsetOf(System::Security::IPermission ^ target);
public abstract bool IsSubsetOf(System.Security.IPermission target);
abstract member IsSubsetOf : System.Security.IPermission -> bool
Public MustOverride Function IsSubsetOf (target As IPermission) As Boolean
매개 변수
- target
- IPermission
하위 집합 관계를 테스트할 사용 권한입니다. 이 사용 권한은 현재 사용 권한과 형식이 같아야 합니다.
반환
현재 사용 권한이 지정된 사용 권한의 하위 집합이면 true이고, 그렇지 않으면 false입니다.
구현
예외
target 매개 변수가 null이 아니고 현재 사용 권한과 형식이 다른 경우
예제
다음 코드 예제에서는 재정의를 보여 주는 IsSubsetOf 메서드입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 CodeAccessPermission 클래스입니다.
public:
virtual bool IsSubsetOf( IPermission^ target ) override
{
#if ( debug )
Console::WriteLine( "************* Entering IsSubsetOf *********************" );
#endif
if ( target == nullptr )
{
Console::WriteLine( "IsSubsetOf: target == null" );
return false;
}
#if ( debug )
Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
#endif
try
{
NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);
// The following check for unrestricted permission is only included as an example for
// permissions that allow the unrestricted state. It is of no value for this permission.
if ( true == operand->m_Unrestricted )
{
return true;
}
else if ( true == this->m_Unrestricted )
{
return false;
}
if ( this->m_Name != nullptr )
{
if ( operand->m_Name == nullptr )
{
return false;
}
if ( this->m_Name->Equals( "" ) )
{
return true;
}
}
if ( this->m_Name->Equals( operand->m_Name ) )
{
return true;
}
else
{
// Check for wild card character '*'.
int i = operand->m_Name->LastIndexOf( "*" );
if ( i > 0 )
{
String^ prefix = operand->m_Name->Substring( 0, i );
if ( this->m_Name->StartsWith( prefix ) )
{
return true;
}
}
}
return false;
}
catch ( InvalidCastException^ )
{
throw gcnew ArgumentException( String::Format( "Argument_WrongType", this->GetType()->FullName ) );
}
}
public override bool IsSubsetOf(IPermission target)
{
#if(debug)
Console.WriteLine ("************* Entering IsSubsetOf *********************");
#endif
if (target == null)
{
Console.WriteLine ("IsSubsetOf: target == null");
return false;
}
#if(debug)
Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
try
{
NameIdPermission operand = ( NameIdPermission)target;
// The following check for unrestricted permission is only included as an example for
// permissions that allow the unrestricted state. It is of no value for this permission.
if (true == operand.m_Unrestricted)
{
return true;
}
else if (true == this.m_Unrestricted)
{
return false;
}
if (this.m_Name != null)
{
if (operand.m_Name == null) return false;
if (this.m_Name == "") return true;
}
if (this.m_Name.Equals (operand.m_Name))
{
return true;
}
else
{
// Check for wild card character '*'.
int i = operand.m_Name.LastIndexOf ("*");
if (i > 0)
{
string prefix = operand.m_Name.Substring (0, i);
if (this.m_Name.StartsWith (prefix))
{
return true;
}
}
}
return false;
}
catch (InvalidCastException)
{
throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
}
}
Public Overrides Function IsSubsetOf(ByVal target As IPermission) As Boolean
#If (Debug) Then
Console.WriteLine("************* Entering IsSubsetOf *********************")
#End If
If target Is Nothing Then
Console.WriteLine("IsSubsetOf: target == null")
Return False
End If
#If (Debug) Then
Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
#End If
Try
Dim operand As NameIdPermission = CType(target, NameIdPermission)
' The following check for unrestricted permission is only included as an example for
' permissions that allow the unrestricted state. It is of no value for this permission.
If True = operand.m_Unrestricted Then
Return True
ElseIf True = Me.m_Unrestricted Then
Return False
End If
If Not (Me.m_name Is Nothing) Then
If operand.m_name Is Nothing Then
Return False
End If
If Me.m_name = "" Then
Return True
End If
End If
If Me.m_name.Equals(operand.m_name) Then
Return True
Else
' Check for wild card character '*'.
Dim i As Integer = operand.m_name.LastIndexOf("*")
If i > 0 Then
Dim prefix As String = operand.m_name.Substring(0, i)
If Me.m_name.StartsWith(prefix) Then
Return True
End If
End If
End If
Return False
Catch
Throw New ArgumentException(String.Format("Argument_WrongType", Me.GetType().FullName))
End Try
End Function
설명
현재 권한 현재 사용 권한과 지정 된 권한으로 완전히 포함 된 작업의 집합을 지정 하는 경우 지정 된 사용 권한의 하위 집합입니다. 예를 들어 C:\example.txt 대한 액세스를 나타내는 사용 권한은 C:\에 대한 액세스를 나타내는 권한의 하위 집합입니다. 이 메서드가 반환 하는 경우 true, 현재 사용 권한과 액세스 권한을 보호 되는 리소스의 지정한 사용 권한에 보다를 나타냅니다.
메서드의 모든 재정의 IsSubsetOf 에 true 대해 다음 문이 필요합니다.
X, Y 및 Z는 null 참조가 아닌 사용자 지정 코드 액세스 권한 개체를 나타내고 U는 무제한 코드 액세스 권한을 나타내고 N은 의 None빈 권한을 PermissionState 나타냅니다.
X. IsSubsetOf(X)는 를 반환합니다
true.X. IsSubsetOf(Y)는 Y와 동일한 값을 반환합니다. X 및 Y가 동일한 사용 권한 집합을 나타내는 경우에만 IsSubsetOf(X)입니다.
X인 경우 IsSubsetOf(Y) 및 Y. IsSubsetOf(Z)는 모두 , X를 반환
true합니다. IsSubsetOf(Z)는 를 반환합니다true.X. IsSubsetOf(U)는 를 반환합니다
true.X. IsSubsetOf(N)는 를 반환합니다
false.N. IsSubsetOf(X)는 를 반환합니다
true.
X 및 Y가 null 참조인 사용자 지정 코드 액세스 권한 개체를 나타내는 경우 X입니다. IsSubsetOf(Y)는 를 반환합니다true.
Z도 null이면 복합 집합 작업 X입니다. Union(Y). 두 null 권한의 합집합이 null 권한이므로 IsSubsetOf(Z)도 를 반환 true 합니다.
구현자 참고
파생 클래스에서 이 메서드를 재정의해야 합니다.