UIPermission.IsSubsetOf-Methode
Bestimmt, ob die aktuelle Berechtigung eine Teilmenge der angegebenen Berechtigung ist.
Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Overrides Function IsSubsetOf ( _
target As IPermission _
) As Boolean
'Usage
Dim instance As UIPermission
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
Parameter
- target
Eine Berechtigung, für die geprüft werden soll, ob sie eine Teilmenge einer anderen Berechtigung ist. Diese Berechtigung muss von demselben Typ wie die aktuelle Berechtigung sein.
Rückgabewert
true, wenn die aktuelle Berechtigung eine Teilmenge der angegebenen Berechtigung ist, andernfalls false.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der target-Parameter ist nicht NULL (Nothing in Visual Basic) und nicht von demselben Typ wie die aktuelle Berechtigung. |
Hinweise
Die aktuelle Berechtigung ist eine Teilmenge der angegebenen Berechtigung, wenn alle für die aktuelle Berechtigung erfolgreichen Anforderungen auch für die angegebene Berechtigung erfolgreich sind. Die angegebene Berechtigung enthält also mindestens die in der Teilmenge enthaltenen Berechtigungen. Damit IsSubsetOf true zurückgibt, müssen sowohl die UIPermissionWindow-Werte als auch die UIPermissionClipboard-Werte der aktuellen Berechtigung mindestens so restriktiv wie die Werte der angegebenen Berechtigung sein.
Beispiel
Das vollständige Beispiel finden Sie unter der UIPermission-Klasse.
' The IsSubsetOf method determines whether the current permission is a
' subset of the specified permission. This demo uses the IsSubsetOf method
' to determine the relationship of two UIPermissionWindow permissions and
' two UIPermissionClipboard permissions.
Private Function IsSubsetOfWindowAndClipboardDemo() As Boolean
Dim returnValue As Boolean = True
Dim ui1, ui2 As UIPermissionWindow
Dim cb1, cb2 As UIPermissionClipboard
Dim uiIdPerm1, uiIdPerm2 As UIPermission
Dim uiGen1 As New UIGenerator()
Dim uiGen2 As New UIGenerator()
uiGen1.ResetIndex()
While uiGen1.CreateUI(ui1, cb1)
uiIdPerm1 = New UIPermission(ui1, cb1)
uiGen2.ResetIndex()
Console.WriteLine("********************************************************" & ControlChars.Lf)
While uiGen2.CreateUI(ui2, cb2)
uiIdPerm2 = New UIPermission(ui2, cb2)
Try
If uiIdPerm1.IsSubsetOf(uiIdPerm2) Then
Console.WriteLine(uiIdPerm1.Window.ToString() & " and " _
& uiIdPerm1.Clipboard.ToString() & " is a subset of " _
& uiIdPerm2.Window.ToString() & " and " & uiIdPerm2.Clipboard.ToString())
Else
Console.WriteLine(uiIdPerm1.Window.ToString() & " and " _
& uiIdPerm1.Clipboard.ToString() & " is not a subset of " _
& uiIdPerm2.Window.ToString() & " and " & uiIdPerm2.Clipboard)
End If
Catch e As Exception
Console.WriteLine("An exception was thrown for subset :" & uiIdPerm1.ToString() _
& ControlChars.Lf & uiIdPerm2.ToString() & ControlChars.Lf & e.ToString())
returnValue = False
End Try
ContinueWhile2:
End While
ContinueWhile1:
End While
Return returnValue
End Function 'IsSubsetOfWindowAndClipboardDemo
' Compare two UIPemissionWindow permissions.
Private Function IsSubsetOfWindowDemo() As Boolean
Dim returnValue As Boolean = True
Dim ui1, ui2 As UIPermissionWindow
Dim uiIdPerm1, uiIdPerm2 As UIPermission
Dim uiGen1 As New UIGenerator()
Dim uiGen2 As New UIGenerator()
uiGen1.ResetIndex()
While uiGen1.CreateUI(ui1)
uiIdPerm1 = New UIPermission(ui1)
uiGen2.ResetIndex()
Console.WriteLine("********************************************************" & ControlChars.Lf)
While uiGen2.CreateUI(ui2)
uiIdPerm2 = New UIPermission(ui2)
Try
If uiIdPerm1.IsSubsetOf(uiIdPerm2) Then
Console.WriteLine(uiIdPerm1.Window.ToString() & " is a subset of " _
& uiIdPerm2.Window.ToString())
Else
Console.WriteLine(uiIdPerm1.Window.ToString() & " is not a subset of " _
& uiIdPerm2.Window.ToString())
End If
Catch e As Exception
Console.WriteLine(("An exception was thrown for subset :" & uiIdPerm1.ToString() _
& ControlChars.Lf & uiIdPerm2.ToString() & ControlChars.Lf & e.ToString()))
returnValue = False
End Try
ContinueWhile2:
End While
ContinueWhile1:
End While
Return returnValue
End Function 'IsSubsetOfWindowDemo
' Compare two UIPermissionClipboard permissions.
Private Function IsSubsetOfClipboardDemo() As Boolean
Dim returnValue As Boolean = True
Dim cb1, cb2 As UIPermissionClipboard
Dim uiIdPerm1, uiIdPerm2 As UIPermission
Dim uiGen1 As New UIGenerator()
Dim uiGen2 As New UIGenerator()
uiGen1.ResetIndex()
While uiGen1.CreateUI(cb1)
uiIdPerm1 = New UIPermission(cb1)
uiGen2.ResetIndex()
Console.WriteLine("********************************************************" & ControlChars.Lf)
While uiGen2.CreateUI(cb2)
uiIdPerm2 = New UIPermission(cb2)
Try
If uiIdPerm1.IsSubsetOf(uiIdPerm2) Then
Console.WriteLine(uiIdPerm1.Clipboard.ToString() & " is a subset of " _
& uiIdPerm2.Clipboard.ToString())
Else
Console.WriteLine(uiIdPerm1.Clipboard.ToString() & " is not a subset of " _
& uiIdPerm2.Clipboard.ToString())
End If
Catch e As Exception
Console.WriteLine("An exception was thrown for subset :" _
& uiIdPerm1.ToString() & ControlChars.Lf & uiIdPerm2.ToString() _
& ControlChars.Lf & e.ToString())
returnValue = False
End Try
ContinueWhile2:
End While
ContinueWhile1:
End While
Return returnValue
End Function 'IsSubsetOfClipboardDemo
// The IsSubsetOf method determines whether the current permission is a
// subset of the specified permission. This demo uses the IsSubsetOf
// method to determine the relationship of two UIPermissionWindow
// permissions and two UIPermissionClipboard permissions.
private bool IsSubsetOfWindowAndClipboardDemo()
{
bool returnValue = true;
UIPermissionWindow ui1, ui2;
UIPermissionClipboard cb1, cb2;
UIPermission uiIdPerm1, uiIdPerm2;
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI( out ui1, out cb1))
{
uiIdPerm1 = new UIPermission(ui1, cb1);
uiGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
while (uiGen2.CreateUI(out ui2, out cb2))
{
uiIdPerm2 = new UIPermission(ui2, cb2);
try
{
if (uiIdPerm1.IsSubsetOf(uiIdPerm2))
{
Console.WriteLine(uiIdPerm1.Window + " and " + uiIdPerm1.Clipboard + " is a subset of " +
uiIdPerm2.Window + " and " + uiIdPerm2.Clipboard);
}
else
{
Console.WriteLine(uiIdPerm1.Window + " and " + uiIdPerm1.Clipboard + " is not a subset of " +
uiIdPerm2.Window + " and " + uiIdPerm2.Clipboard);
}
}
catch (Exception e)
{
Console.WriteLine("An exception was thrown for subset :" + uiIdPerm1 + "\n" +
uiIdPerm2 + "\n" + e);
returnValue = false;
}
}
}
return returnValue;
}
// Compare two UIPemissionWindow permissions.
private bool IsSubsetOfWindowDemo()
{
bool returnValue = true;
UIPermissionWindow ui1, ui2;
UIPermission uiIdPerm1, uiIdPerm2;
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(out ui1))
{
uiIdPerm1 = new UIPermission(ui1);
uiGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
while (uiGen2.CreateUI(out ui2))
{
uiIdPerm2 = new UIPermission(ui2);
try
{
if (uiIdPerm1.IsSubsetOf(uiIdPerm2))
{
Console.WriteLine(uiIdPerm1.Window + " is a subset of " + uiIdPerm2.Window);
}
else
{
Console.WriteLine(uiIdPerm1.Window + " is not a subset of " + uiIdPerm2.Window);
}
}
catch (Exception e)
{
Console.WriteLine("An exception was thrown for subset :" + uiIdPerm1 + "\n" +
uiIdPerm2 + "\n" + e);
returnValue = false;
}
}
}
return returnValue;
}
// Compare two UIPermissionClipboard permissions.
private bool IsSubsetOfClipboardDemo()
{
bool returnValue = true;
UIPermissionClipboard cb1, cb2;
UIPermission uiIdPerm1, uiIdPerm2;
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(out cb1))
{
uiIdPerm1 = new UIPermission(cb1);
uiGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
while (uiGen2.CreateUI(out cb2))
{
uiIdPerm2 = new UIPermission(cb2);
try
{
if (uiIdPerm1.IsSubsetOf(uiIdPerm2))
{
Console.WriteLine(uiIdPerm1.Clipboard + " is a subset of " + uiIdPerm2.Clipboard);
}
else
{
Console.WriteLine(uiIdPerm1.Clipboard + " is not a subset of " + uiIdPerm2.Clipboard);
}
}
catch (Exception e)
{
Console.WriteLine("An exception was thrown for subset :" + uiIdPerm1 + "\n" +
uiIdPerm2 + "\n" + e);
returnValue = false;
}
}
}
return returnValue;
}
// The IsSubsetOf method determines whether the current permission is a
// subset of the specified permission. This demo uses the IsSubsetOf
// method to determine the relationship of two UIPermissionWindow
// permissions and two UIPermissionClipboard permissions.
bool IsSubsetOfWindowAndClipboardDemo()
{
bool returnValue = true;
UIPermissionWindow ui1;
UIPermissionWindow ui2;
UIPermissionClipboard cb1;
UIPermissionClipboard cb2;
UIPermission^ uiIdPerm1;
UIPermission^ uiIdPerm2;
UIGenerator^ uiGen1 = gcnew UIGenerator;
UIGenerator^ uiGen2 = gcnew UIGenerator;
uiGen1->ResetIndex();
while ( uiGen1->CreateUI( &ui1, &cb1 ) )
{
uiIdPerm1 = gcnew UIPermission( ui1, cb1 );
uiGen2->ResetIndex();
Console::WriteLine( "********************************************************\n" );
while ( uiGen2->CreateUI( &ui2, &cb2 ) )
{
uiIdPerm2 = gcnew UIPermission( ui2, cb2 );
try
{
if ( uiIdPerm1->IsSubsetOf( uiIdPerm2 ) )
{
Console::WriteLine( "{0} and {1} is a subset of {2} and {3}", uiIdPerm1->Window, uiIdPerm1->Clipboard, uiIdPerm2->Window, uiIdPerm2->Clipboard );
}
else
{
Console::WriteLine( "{0} and {1} is not a subset of {2} and {3}", uiIdPerm1->Window, uiIdPerm1->Clipboard, uiIdPerm2->Window, uiIdPerm2->Clipboard );
}
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception was thrown for subset :{0}\n{1}\n{2}", uiIdPerm1, uiIdPerm2, e );
returnValue = false;
}
}
}
return returnValue;
}
// Compare two UIPemissionWindow permissions.
bool IsSubsetOfWindowDemo()
{
bool returnValue = true;
UIPermissionWindow ui1;
UIPermissionWindow ui2;
UIPermission^ uiIdPerm1;
UIPermission^ uiIdPerm2;
UIGenerator^ uiGen1 = gcnew UIGenerator;
UIGenerator^ uiGen2 = gcnew UIGenerator;
uiGen1->ResetIndex();
while ( uiGen1->CreateUI( &ui1 ) )
{
uiIdPerm1 = gcnew UIPermission( ui1 );
uiGen2->ResetIndex();
Console::WriteLine( "********************************************************\n" );
while ( uiGen2->CreateUI( &ui2 ) )
{
uiIdPerm2 = gcnew UIPermission( ui2 );
try
{
if ( uiIdPerm1->IsSubsetOf( uiIdPerm2 ) )
{
Console::WriteLine( "{0} is a subset of {1}", uiIdPerm1->Window, uiIdPerm2->Window );
}
else
{
Console::WriteLine( "{0} is not a subset of {1}", uiIdPerm1->Window, uiIdPerm2->Window );
}
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception was thrown for subset :{0}\n{1}\n{2}", uiIdPerm1, uiIdPerm2, e );
returnValue = false;
}
}
}
return returnValue;
}
// Compare two UIPermissionClipboard permissions.
bool IsSubsetOfClipboardDemo()
{
bool returnValue = true;
UIPermissionClipboard cb1;
UIPermissionClipboard cb2;
UIPermission^ uiIdPerm1;
UIPermission^ uiIdPerm2;
UIGenerator^ uiGen1 = gcnew UIGenerator;
UIGenerator^ uiGen2 = gcnew UIGenerator;
uiGen1->ResetIndex();
while ( uiGen1->CreateUI( &cb1 ) )
{
uiIdPerm1 = gcnew UIPermission( cb1 );
uiGen2->ResetIndex();
Console::WriteLine( "********************************************************\n" );
while ( uiGen2->CreateUI( &cb2 ) )
{
uiIdPerm2 = gcnew UIPermission( cb2 );
try
{
if ( uiIdPerm1->IsSubsetOf( uiIdPerm2 ) )
{
Console::WriteLine( "{0} is a subset of {1}", uiIdPerm1->Clipboard, uiIdPerm2->Clipboard );
}
else
{
Console::WriteLine( "{0} is not a subset of {1}", uiIdPerm1->Clipboard, uiIdPerm2->Clipboard );
}
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception was thrown for subset :{0}\n{1}\n{2}", uiIdPerm1, uiIdPerm2, e );
returnValue = false;
}
}
}
return returnValue;
}
// The IsSubsetOf method determines whether the current permission is
// a subset of the specified permission.
// This demo uses the IsSubsetOf method to determine the relationship
// of two UIPermissionWindow permissions and two UIPermissionClipboard
// permissions.
private boolean IsSubsetOfWindowAndClipboardDemo()
{
boolean returnValue = true;
UIPermissionWindow ui1[] = new UIPermissionWindow[1];
UIPermissionWindow ui2[] = new UIPermissionWindow[1];
UIPermissionClipboard cb1[] = new UIPermissionClipboard[1];
UIPermissionClipboard cb2[] = new UIPermissionClipboard[1];
UIPermission uiIdPerm1[] = new UIPermission[1];
UIPermission uiIdPerm2[] = new UIPermission[1];
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(uiIdPerm1, ui1, cb1)) {
if (uiIdPerm1[0] == null) {
continue;
}
uiGen2.ResetIndex();
Console.WriteLine("**************************************"
+ "******************\n");
while (uiGen2.CreateUI(uiIdPerm2, ui2, cb2)) {
if (uiIdPerm2[0] == null) {
continue;
}
try {
if (uiIdPerm1[0].IsSubsetOf(uiIdPerm2[0])) {
Console.WriteLine((uiIdPerm1[0].get_Window()
+ " and " + uiIdPerm1[0].get_Clipboard()
+ " is a subset of " + uiIdPerm2[0].get_Window()
+ " and " + uiIdPerm2[0].get_Clipboard()));
}
else {
Console.WriteLine((uiIdPerm1[0].get_Window()
+ " and " + uiIdPerm1[0].get_Clipboard()
+ " is not a subset of " + uiIdPerm2[0].get_Window()
+ " and " + uiIdPerm2[0].get_Clipboard()));
}
}
catch (System.Exception e) {
Console.WriteLine(("An exception was "
+ "thrown for subset :"
+ uiIdPerm1[0] + "\n" + uiIdPerm2[0] + "\n" + e));
returnValue = false;
}
}
}
return returnValue;
} //IsSubsetOfWindowAndClipboardDemo
// Compare two UIPemissionWindow permissions.
private boolean IsSubsetOfWindowDemo()
{
boolean returnValue = true;
UIPermissionWindow ui1[] = new UIPermissionWindow[1];
UIPermissionWindow ui2[] = new UIPermissionWindow[1];
UIPermission uiIdPerm1[] = new UIPermission[1];
UIPermission uiIdPerm2[] = new UIPermission[1];
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(uiIdPerm1, ui1)) {
if (uiIdPerm1[0] == null) {
continue;
}
uiGen2.ResetIndex();
Console.WriteLine("********************************"
+ "************************\n");
while (uiGen2.CreateUI(uiIdPerm2, ui2)) {
if (uiIdPerm2[0] == null) {
continue;
}
try {
if (uiIdPerm1[0].IsSubsetOf(uiIdPerm2[0])) {
Console.WriteLine((uiIdPerm1[0].get_Window()
+ " is a subset of " + uiIdPerm2[0].get_Window()));
}
else {
Console.WriteLine((uiIdPerm1[0].get_Window()
+ " is not a subset of "
+ uiIdPerm2[0].get_Window()));
}
}
catch (System.Exception e) {
Console.WriteLine(("An exception was "
+ "thrown for subset :" + uiIdPerm1[0]
+ "\n" + uiIdPerm2[0] + "\n" + e));
returnValue = false;
}
}
}
return returnValue;
} //IsSubsetOfWindowDemo
// Compare two UIPermissionClipboard permissions.
private boolean IsSubsetOfClipboardDemo()
{
boolean returnValue = true;
UIPermissionClipboard cb1[] = new UIPermissionClipboard[1];
UIPermissionClipboard cb2[] = new UIPermissionClipboard[1];
UIPermission uiIdPerm1[] = new UIPermission[1];
UIPermission uiIdPerm2[] = new UIPermission[1];
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(uiIdPerm1, cb1)) {
if (uiIdPerm1[0] == null) {
continue;
}
uiGen2.ResetIndex();
Console.WriteLine("********************************"
+ "************************\n");
while (uiGen2.CreateUI(uiIdPerm2, cb2)) {
if (uiIdPerm2[0] == null) {
continue;
}
try {
if (uiIdPerm1[0].IsSubsetOf(uiIdPerm2[0])) {
Console.WriteLine((uiIdPerm1[0].get_Clipboard()
+ " is a subset of "
+ uiIdPerm2[0].get_Clipboard()));
}
else {
Console.WriteLine((uiIdPerm1[0].get_Clipboard()
+ " is not a subset of "
+ uiIdPerm2[0].get_Clipboard()));
}
}
catch (System.Exception e) {
Console.WriteLine(("An exception was thrown "
+ "for subset :" + uiIdPerm1[0] + "\n"
+ uiIdPerm2[0] + "\n" + e));
returnValue = false;
}
}
}
return returnValue;
} //IsSubsetOfClipboardDemo
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
UIPermission-Klasse
UIPermission-Member
System.Security.Permissions-Namespace