StrongNameIdentityPermission.Copy 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立並傳回目前權限的相同複本。
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
傳回
目前權限的複本。
範例
下列程式代碼範例顯示 方法的行為 Copy 。 這個範例是提供給 類別之較大範例的 StrongNameIdentityPermission 一部分。 此範例的最佳用法是建置和執行整個範例,並檢視其輸出。
注意
程式代碼範例旨在顯示 方法的行為,而不是示範其用法。 一般而言,安全性基礎結構會使用許可權類別的方法;它們通常不會用於應用程式。
//Copy creates and returns an identical copy of the current permission.
bool CopyDemo()
{
bool returnValue = true;
StrongNameIdentityPermission^ snIdPerm1;
StrongNameIdentityPermission^ snIdPerm2;
snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
snIdPerm2 = dynamic_cast<StrongNameIdentityPermission^>(snIdPerm1->Copy());
Console::WriteLine("Result of copy = " + snIdPerm2->ToString() + "\n");
return returnValue;
}
//Copy creates and returns an identical copy of the current permission.
private bool CopyDemo()
{
bool returnValue = true;
StrongNameIdentityPermission snIdPerm1, snIdPerm2;
snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
snIdPerm2 = (StrongNameIdentityPermission)snIdPerm1.Copy();
Console.WriteLine("Result of copy = " + snIdPerm2.ToString() + "\n");
return returnValue;
}
'Copy creates and returns an identical copy of the current permission.
Private Function CopyDemo() As Boolean
Dim returnValue As Boolean = True
Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)
snIdPerm2 = CType(snIdPerm1.Copy(), StrongNameIdentityPermission)
Console.WriteLine("Result of copy = " + snIdPerm2.ToString() + vbLf)
Return returnValue
End Function 'CopyDemo
備註
許可權的複本代表與原始許可權相同的資源存取權。