DataProtectionPermission::Union Method (IPermission^)

 

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

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

public:
virtual IPermission^ Union(
	IPermission^ target
) override

Parameters

target
Type: System.Security::IPermission^

A permission to combine with the current permission. It must be of 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.

Exception Condition
ArgumentException

target is not null and does not specify a permission of the same type as the current permission.

The result of a call to Union is a permission that represents all operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.

The following code example shows the use of the Union method. This code example is part of a larger example provided for the DataProtectionPermission class.

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

Console::WriteLine( "Creating the union of the second and first "
"permissions." );
sp4 = dynamic_cast<DataProtectionPermission^>(sp2->Union( sp1 ));
Console::WriteLine( "Result of the union of the second permission "
"with the first: {0}", sp4->Flags );

.NET Framework
Available since 2.0
Return to top
Show: