Freigeben über


UIPermission.Copy-Methode

Erstellt eine identische Kopie der aktuellen Berechtigung und gibt die Kopie zurück.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overrides Function Copy As IPermission
'Usage
Dim instance As UIPermission
Dim returnValue As IPermission

returnValue = instance.Copy
public override IPermission Copy ()
public:
virtual IPermission^ Copy () override
public IPermission Copy ()
public override function Copy () : IPermission

Rückgabewert

Eine Kopie der aktuellen Berechtigung.

Hinweise

Eine Kopie der Berechtigung stellt den gleichen Ressourcenzugriff dar wie die ursprüngliche Berechtigung.

Beispiel

Das vollständige Beispiel finden Sie unter der UIPermission-Klasse.

    Private Function CopyDemo() As Boolean
        Dim returnValue As Boolean = True

        Dim ui1 As UIPermissionWindow
        Dim cb1 As UIPermissionClipboard
        Dim uiIdPerm1, uiIdPerm2 As UIPermission

        Dim uiGen1 As New UIGenerator()
        Dim uiGen2 As New UIGenerator()

        uiGen1.ResetIndex()
        While uiGen1.CreateUI(ui1, cb1)
            uiIdPerm1 = New UIPermission(ui1, cb1)
            uiGen2.ResetIndex()
            Console.WriteLine("********************************************************" & ControlChars.Lf)
            Try
                uiIdPerm2 = CType(uiIdPerm1.Copy(), UIPermission)
                Console.WriteLine(("Result of copy = " & uiIdPerm2.ToString()))

            Catch e As Exception
                Console.WriteLine(("The copy failed :" & uiIdPerm1.ToString() & e.ToString()))
                GoTo ContinueWhile1
            End Try
ContinueWhile1:
        End While
        Return returnValue
    End Function 'CopyDemo
private bool CopyDemo()
{
    bool returnValue = true;

    UIPermissionWindow ui1;
    UIPermissionClipboard cb1;
    UIPermission uiIdPerm1, uiIdPerm2;

    UIGenerator uiGen1 = new UIGenerator();
    UIGenerator uiGen2 = new UIGenerator();

    uiGen1.ResetIndex();
    while (uiGen1.CreateUI( out ui1, out cb1))
    {
        uiIdPerm1 = new UIPermission(ui1, cb1);
        uiGen2.ResetIndex();
        Console.WriteLine("********************************************************\n");
        try
        {
            uiIdPerm2 = (UIPermission)uiIdPerm1.Copy();
            Console.WriteLine("Result of copy = " + uiIdPerm2.ToString());

        }
        catch (Exception e)
        {
            Console.WriteLine("The copy failed :" + uiIdPerm1.ToString() + e);
            continue;
        }
    }
    return returnValue;
}
bool CopyDemo()
{
   bool returnValue = true;
   UIPermissionWindow ui1;
   UIPermissionClipboard cb1;
   UIPermission^ uiIdPerm1;
   UIPermission^ uiIdPerm2;
   UIGenerator^ uiGen1 = gcnew UIGenerator;
   UIGenerator^ uiGen2 = gcnew UIGenerator;
   uiGen1->ResetIndex();
   while ( uiGen1->CreateUI(   &ui1,  &cb1 ) )
   {
      uiIdPerm1 = gcnew UIPermission( ui1, cb1 );

      uiGen2->ResetIndex();
      Console::WriteLine( "********************************************************\n" );
      try
      {
         
         uiIdPerm2 = dynamic_cast<UIPermission^>(uiIdPerm1->Copy());
         Console::WriteLine( "Result of copy = {0}", uiIdPerm2 );
         
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "The copy failed :{0}{1}", uiIdPerm1, e );
         continue;
      }

   }

   return returnValue;
}

//Copy creates and returns an identical copy of the current permission.
private boolean CopyDemo()
{
    boolean returnValue = true;
    UIPermissionWindow ui1[] = new UIPermissionWindow[1];
    UIPermissionClipboard cb1[] = new UIPermissionClipboard[1];
    UIPermission uiIdPerm1[] = new UIPermission[1];
    UIPermission uiIdPerm2 = null;
    UIGenerator uiGen1 = new UIGenerator();
    UIGenerator uiGen2 = new UIGenerator();

    uiGen1.ResetIndex();
    while (uiGen1.CreateUI(uiIdPerm1, ui1, cb1)) {
        if (uiIdPerm1[0] == null) {
            continue;
        }
        uiGen2.ResetIndex();
        Console.WriteLine("**********************************" 
            + "**********************\n");
        try {
            uiIdPerm2 = ((UIPermission)(uiIdPerm1[0].Copy()));
            Console.WriteLine(("Result of copy = " 
                + uiIdPerm2.ToString()));
        catch (System.Exception e) {
            Console.WriteLine(("The copy failed :" 
                + uiIdPerm1[0].ToString() + e));
            continue;
        }
    }
    return returnValue;
} //CopyDemo

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

UIPermission-Klasse
UIPermission-Member
System.Security.Permissions-Namespace