DataProtectionPermission.Union(IPermission) 方法

定义

创建一个权限,该权限是当前权限与指定权限的并集。

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

参数

target
IPermission

与当前权限合并的权限。 它必须与当前权限属于同一类型。

返回

IPermission

表示同时兼具当前权限和指定权限的新权限。

例外

target 不是 null,并且未指定同一类型的权限为当前权限。

示例

下面的代码示例演示了该方法 Union 的使用。 此代码示例是为类提供的大型示例的 DataProtectionPermission 一部分。

备注

代码示例旨在显示方法的行为,而不是演示其用法。 一般情况下,安全基础结构使用权限类的方法;它们通常不用于应用程序。

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())

注解

调用 Union 的结果是表示当前权限和指定权限所表示的所有操作的权限。 传递任一权限的任何要求都会通过其联合。

适用于