ערוך

שתף באמצעות


DataProtectionPermission.Union(IPermission) Method

Definition

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

public:
 override System::Security::IPermission ^ Union(System::Security::IPermission ^ target);
public override System.Security.IPermission Union (System.Security.IPermission target);
override this.Union : System.Security.IPermission -> System.Security.IPermission
Public Overrides Function Union (target As IPermission) As IPermission

Parameters

target
IPermission

A permission to combine with the current permission. It must be of the same type as the current permission.

Returns

A new permission that represents the union of the current permission and the specified permission.

Exceptions

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

Examples

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.

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.

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 );
Console.WriteLine("Creating the union of the second and first " +
    "permissions.");
sp4 = (DataProtectionPermission)sp2.Union(sp1);
Console.WriteLine("Result of the union of the second permission " +
    "with the first: " + sp4.Flags);
Console.WriteLine("Creating the union of the second and first " + "permissions.")
sp4 = CType(sp2.Union(sp1), DataProtectionPermission)
Console.WriteLine("Result of the union of the second permission with the first: " + sp4.Flags.ToString())

Remarks

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.

Applies to