Freigeben über


ZoneIdentityPermission.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 ZoneIdentityPermission
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 einer Berechtigung stellt denselben Ressourcenzugriff dar wie die ursprüngliche Berechtigung.

Beispiel

        'Copy creates and returns an identical copy of the current permission.
        Private Function CopyDemo() As Boolean

            Dim returnValue As Boolean = True

            Dim zone1 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2 As ZoneIdentityPermission

            Dim zoneGen1 As New ZoneGenerator()
            Dim zoneGen2 As New ZoneGenerator()

            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)

                zoneGen2.ResetIndex()
                Console.WriteLine("********************************************************" & ControlChars.Cr)
                Try
                    zoneIdPerm2 = CType(zoneIdPerm1.Copy(), ZoneIdentityPermission)
                    Console.WriteLine(("Result of copy = " & zoneIdPerm2.ToString()))

                Catch e As Exception
                    Console.WriteLine(("Copy failed :" & zoneIdPerm1.ToString() & e.ToString()))
                    GoTo ContinueWhile1
                End Try
ContinueWhile1:
            End While
            Return returnValue
        End Function 'CopyDemo
//Copy creates and returns an identical copy of the current permission.
private bool CopyDemo()
{

    bool returnValue = true;

    SecurityZone zone1;
    ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;

    ZoneGenerator zoneGen1 = new ZoneGenerator();
    ZoneGenerator zoneGen2 = new ZoneGenerator();

    zoneGen1.ResetIndex();
    while (zoneGen1.CreateZone(out zone1))
    {
        zoneIdPerm1 = new ZoneIdentityPermission( zone1);
        zoneGen2.ResetIndex();
        Console.WriteLine("********************************************************\n");
        try
        {
            zoneIdPerm2 = (ZoneIdentityPermission)zoneIdPerm1.Copy();
            Console.WriteLine("Result of copy = " + zoneIdPerm2.ToString());

        }
        catch (Exception e)
        {
            Console.WriteLine("Copy failed :" + zoneIdPerm1.ToString() + e);
            continue;
        }
    }
    return returnValue;
}
//Copy creates and returns an identical copy of the current permission.
bool CopyDemo()
{
   bool returnValue = true;
   SecurityZone zone1;
   ZoneIdentityPermission^ zoneIdPerm1;
   ZoneIdentityPermission^ zoneIdPerm2;
   ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
   ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
   zoneGen1->ResetIndex();
   while ( zoneGen1->CreateZone(  &zone1 ) )
   {
      zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
      zoneGen2->ResetIndex();
      Console::WriteLine( "********************************************************\n" );
      try
      {
         zoneIdPerm2 = dynamic_cast<ZoneIdentityPermission^>(zoneIdPerm1->Copy());
         Console::WriteLine( "Result of copy = {0}", zoneIdPerm2 );
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "Copy failed : {0}{1}", zoneIdPerm1, e );
         continue;
      }

   }

   return returnValue;
}

//Copy creates and returns an identical copy of the current permission.
private boolean CopyDemo()
{
    boolean returnValue = true;
    SecurityZone zone1[] = new SecurityZone[1];
    ZoneIdentityPermission zoneIdPerm1[] = new ZoneIdentityPermission[1];
    ZoneIdentityPermission zoneIdPerm2 = null;
    ZoneGenerator zoneGen1 = new ZoneGenerator();
    ZoneGenerator zoneGen2 = new ZoneGenerator();

    zoneGen1.ResetIndex();
    while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
        if (zoneIdPerm1[0] == null) {
            continue;
        }
        zoneGen2.ResetIndex();
        Console.WriteLine("**********************************" 
            + "**********************\n");
        try {
            zoneIdPerm2 = ((ZoneIdentityPermission)(zoneIdPerm1[0].Copy()));
            Console.WriteLine(("Result of copy = " 
                + zoneIdPerm2.ToString()));
        }
        catch (System.Exception e) {
            Console.WriteLine(("Copy failed :" 
                + zoneIdPerm1[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

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