UIPermission::IsSubsetOf Method (IPermission^)
Determines whether the current permission is a subset of the specified permission.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- target
-
Type:
System.Security::IPermission^
A permission to test for the subset relationship. This permission must be the same type as the current permission.
Return Value
Type: System::Booleantrue if the current permission is a subset of the specified permission; otherwise, false.
Implements
IPermission::IsSubsetOf(IPermission^)| Exception | Condition |
|---|---|
| ArgumentException | The target parameter is not null and is not of the same type as the current permission. |
The current permission is a subset of the specified permission if all demands that succeed for the current permission also succeed for the specified permission. That is, the specified permission contains at least the permissions contained in the subset. For IsSubsetOf to return true, both the UIPermissionWindow and UIPermissionClipboard values of the current permission must be equal to or less permissive than the values of the specified permission.
The following code example shows the behavior of the IsSubsetOf method. This example is part of a larger example provided for the UIPermission class.
Note |
|---|
The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications. |
// IsSubsetOf determines whether the current permission is a subset of the specified permission. void IsSubsetOfDemo() { Console::WriteLine("\n********************** IsSubsetOf() Demo **********************\n"); UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows); UIPermission ^ uiPerm2 = gcnew UIPermission(UIPermissionWindow::SafeSubWindows); Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm1->Window, uiPerm1->IsSubsetOf(uiPerm2)?"":"not ", uiPerm2->Window); Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm2->Window, uiPerm2->IsSubsetOf(uiPerm1)?"":"not ", uiPerm1->Window); uiPerm1 = gcnew UIPermission(UIPermissionClipboard::AllClipboard); uiPerm2 = gcnew UIPermission(UIPermissionClipboard::OwnClipboard); Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm1->Clipboard, uiPerm1->IsSubsetOf(uiPerm2)?"":"not ", uiPerm2->Clipboard); Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm2->Clipboard, uiPerm2->IsSubsetOf(uiPerm1)?"":"not ", uiPerm1->Clipboard); }
Available since 1.1
