UIPermission.Union Method
Creates a permission that is the union of the permission and the specified permission.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- target
- Type: System.Security.IPermission
A permission to combine with the current permission. It must be the same type as the current permission.
Return Value
Type: System.Security.IPermissionA new permission that represents the union of the current permission and the specified permission.
Implements
IPermission.Union(IPermission)| Exception | Condition |
|---|---|
| ArgumentException | The target parameter is not Nothing and is not of the same type as the current permission. |
The result of a call to Union is a permission that represents all the operations represented by the current permission as well as all the operations represented by the specified permission. Specifically, it represents the most permissive values of UIPermissionWindow and UIPermissionClipboard from those in the current permission and the specified permission.
The following code example shows the behavior of the Union 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. |
' Union creates a new permission that is the union of the current permission
' and the specified permission.
Private Shared Sub UnionDemo()
Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
Dim uiPerm2 As New UIPermission(UIPermissionWindow.SafeSubWindows)
Dim p3 As UIPermission = CType(uiPerm1.Union(uiPerm2), UIPermission)
Try
If Not (p3 Is Nothing) Then
Console.WriteLine("The union of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is " + vbLf + vbTab + p3.Window.ToString() + vbLf)
Else
Console.WriteLine("The union of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is null." + vbLf)
End If
Catch e As SystemException
Console.WriteLine("The union of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " failed.")
Console.WriteLine(e.Message)
End Try
End Sub 'UnionDemo
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note