UIPermission.Union Method

Creates a permission that is the union of the permission and the specified permission.

Namespace:  System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Overrides Function Union ( _
	target As IPermission _
) As IPermission

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.IPermission
A new permission that represents the union of the current permission and the specified permission.

Implements

IPermission.Union(IPermission)

ExceptionCondition
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.

NoteNote

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft