UIPermission.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 behavior of the Copy method. この例は、UIPermission クラス用に用意されている大規模な例の一部です。This example is part of a larger example provided for the UIPermission 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.

//Copy creates and returns an identical copy of the current permission.
void CopyDemo()
{
    Console::WriteLine("\n*************************  Copy() Demo *************************\n");

    UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
    UIPermission ^ uiPerm2 = gcnew UIPermission(PermissionState::None);
    uiPerm2 = (UIPermission ^)uiPerm1->Copy();
    if (uiPerm2 != nullptr)
        Console::WriteLine("The copy succeeded:  " + uiPerm2->ToString());
}
//Copy creates and returns an identical copy of the current permission.
private static void CopyDemo()
{

    UIPermission uiPerm1 = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
    UIPermission uiPerm2 = new UIPermission(PermissionState.None);
    uiPerm2 = (UIPermission)uiPerm1.Copy();
    if (uiPerm2 != null)
    {
        Console.WriteLine("The copy succeeded:  " + uiPerm2.ToString() + " \n");
    }
}
'Copy creates and returns an identical copy of the current permission.
Private Shared Sub CopyDemo()

    Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
    Dim uiPerm2 As New UIPermission(PermissionState.None)
    uiPerm2 = CType(uiPerm1.Copy(), UIPermission)
    If Not (uiPerm2 Is Nothing) Then
        Console.WriteLine("The copy succeeded:  " + uiPerm2.ToString() + " " + vbLf)
    End If

End Sub

注釈

アクセス許可のコピーは、元のアクセス許可と同じリソースへのアクセスを表します。A copy of the permission represents the same access to resources as the original permission.

適用対象