DataProtectionPermission.Copy 方法

定义

创建并返回当前权限的相同副本。

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

返回

IPermission

当前权限的副本。

示例

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

备注

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

Console::WriteLine( "Copying the second permission to the fourth "
"permission." );
sp4 = dynamic_cast<DataProtectionPermission^>(sp2->Copy());
rc = sp4->Equals( sp2 );
Console::WriteLine( "Is the fourth permission equal to the second "
"permission? {0}", (rc ? (String^)"Yes" : "No") );
Console.WriteLine("Copying the second permission to the fourth " +
    "permission.");
sp4 = (DataProtectionPermission)sp2.Copy();
rc = sp4.Equals(sp2);
Console.WriteLine("Is the fourth permission equal to the second " +
    "permission? " + (rc ? "Yes" : "No"));
Console.WriteLine("Copying the second permission to the fourth " + "permission.")
sp4 = CType(sp2.Copy(), DataProtectionPermission)
rc = sp4.Equals(sp2)
Console.WriteLine("Is the fourth permission equal to the second " + "permission? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements

注解

权限的副本表示对资源的访问权限与原始权限相同的。

适用于