DataProtectionPermission.Copy 方法
定义
创建并返回当前权限的相同副本。Creates and returns an identical copy of the current permission.
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
返回
当前权限的副本。A copy of the current permission.
示例
下面的代码示例演示方法的用法 Copy 。The following code example shows the use of the Copy method. 此代码示例是为类提供的更大示例的一部分 DataProtectionPermission 。This code example is part of a larger example provided for the DataProtectionPermission class.
备注
此代码示例旨在显示方法的行为,而不是演示方法的用法。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( "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
注解
权限的副本表示对资源的相同访问权限。A copy of the permission represents the same access to resources as the original permission.