Freigeben über


IsolatedStorageFilePermission.Union-Methode

Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.

Erstellt eine Berechtigung als Gesamtmenge der aktuellen und der angegebenen Berechtigung.

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

Syntax

'Declaration
Public Overrides Function Union ( _
    target As IPermission _
) As IPermission
'Usage
Dim instance As IsolatedStorageFilePermission
Dim target As IPermission
Dim returnValue As IPermission

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

Parameter

  • target
    Eine Berechtigung, die mit der aktuellen Berechtigung kombiniert werden soll. Diese muss von demselben Typ wie die aktuelle Berechtigung sein.

Rückgabewert

Eine neue Berechtigung, die die Gesamtmenge der aktuellen und der angegebenen Berechtigung darstellt.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

Der target-Parameter ist nicht NULL (Nothing in Visual Basic) und nicht von demselben Typ wie die aktuelle Berechtigung.

Hinweise

Das Ergebnis eines Aufrufs von Union ist eine Berechtigung, die alle Vorgänge darstellt, die sowohl durch die aktuelle als auch die angegebene Berechtigung dargestellt werden. Anforderungen, die eine der beiden Berechtigungen erfolgreich durchlaufen, durchlaufen auch deren Gesamtmenge erfolgreich.

Beispiel

Im folgenden Code wird die Verwendung der Union-Methode veranschaulicht. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels für die IsolatedStorageFilePermission-Klasse.

Private Sub UnionDemo()
    Console.WriteLine(ControlChars.Lf + "Union demo.")
    Dim isfp0 As New IsolatedStorageFilePermission(PermissionState.Unrestricted)
    Dim isfp1 As New IsolatedStorageFilePermission(PermissionState.Unrestricted)
    Dim isfp2 As New IsolatedStorageFilePermission(PermissionState.None)
    Dim isfp3 As New IsolatedStorageFilePermission(PermissionState.None)

    Dim t As IsolatedStorageFilePermission = CType(isfp0.Union(isfp1), IsolatedStorageFilePermission)
    If True = t.IsUnrestricted() Then
        Console.WriteLine("The union of two PermissionState.Unrestricted permissions is unrestricted.")
    Else
        Console.WriteLine(("Union demo failed because the union of two PermissionState.Unrestricted permissions " + ControlChars.Lf + ControlChars.Tab + "should be unrestricted"))
    End If

    t = CType(isfp0.Union(isfp2), IsolatedStorageFilePermission)
    If True = t.IsUnrestricted() Then
        Console.WriteLine(("The union of a PermissionState.Unrestricted and a PermissionState.None " + ControlChars.Lf + ControlChars.Tab + "permission is unrestricted."))
    Else
        Console.WriteLine(("Union demo failed because the union of a PermissionState.Unrestricted and a " + ControlChars.Lf + ControlChars.Tab + "PermissionState.None permission should be unrestricted."))
    End If


    t = CType(isfp2.Union(isfp3), IsolatedStorageFilePermission)
    If Nothing Is t Then
        Console.WriteLine("Union failed because the union of two PermissionState.None permissions should not be null.")
        Console.WriteLine(t.ToString())
    Else
        Console.WriteLine("The union of two PermissionState.None permissions is none.")
    End If
End Sub 'UnionDemo
private void UnionDemo()
{
    Console.WriteLine("\nUnion demo.");
    IsolatedStorageFilePermission isfp0 = new IsolatedStorageFilePermission(PermissionState.Unrestricted);
    IsolatedStorageFilePermission isfp1 = new IsolatedStorageFilePermission(PermissionState.Unrestricted);
    IsolatedStorageFilePermission isfp2 = new IsolatedStorageFilePermission(PermissionState.None);
    IsolatedStorageFilePermission isfp3 = new IsolatedStorageFilePermission(PermissionState.None);

    IsolatedStorageFilePermission t = (IsolatedStorageFilePermission)isfp0.Union(isfp1);
    if (true == t.IsUnrestricted())
    {
        Console.WriteLine("The union of two PermissionState.Unrestricted permissions is unrestricted.");
    }
    else
    {
        Console.WriteLine
            ("Union demo failed because the union of two PermissionState.Unrestricted permissions " +
            "\n\tshould be unrestricted");
    }

    t = (IsolatedStorageFilePermission)isfp0.Union(isfp2);
    if (true == t.IsUnrestricted())
    {
        Console.WriteLine
            ("The union of a PermissionState.Unrestricted and a PermissionState.None " +
            "\n\tpermission is unrestricted.");
    }
    else
    {
        Console.WriteLine
            ("Union demo failed because the union of a PermissionState.Unrestricted and a " +
            "\n\tPermissionState.None permission should be unrestricted.");
    }


    t = (IsolatedStorageFilePermission)isfp2.Union(isfp3);
    if (null != t)
    {
        Console.WriteLine("The union of two PermissionState.None permissions is none.");
    }
    else
    {
        Console.WriteLine
            ("Union failed because the union of two PermissionState.None permissions should not be null.");
        Console.WriteLine(t.ToString());
    }
}
void UnionDemo()
{
   Console::WriteLine( "\nUnion demo." );
   IsolatedStorageFilePermission^ isfp0 = gcnew IsolatedStorageFilePermission( PermissionState::Unrestricted );
   IsolatedStorageFilePermission^ isfp1 = gcnew IsolatedStorageFilePermission( PermissionState::Unrestricted );
   IsolatedStorageFilePermission^ isfp2 = gcnew IsolatedStorageFilePermission( PermissionState::None );
   IsolatedStorageFilePermission^ isfp3 = gcnew IsolatedStorageFilePermission( PermissionState::None );
   IsolatedStorageFilePermission^ t = dynamic_cast<IsolatedStorageFilePermission^>(isfp0->Union( isfp1 ));
   if ( true == t->IsUnrestricted() )
   {
      Console::WriteLine( "The union of two PermissionState.Unrestricted permissions is unrestricted." );
   }
   else
   {
      Console::WriteLine( "Union demo failed because the union of two PermissionState.Unrestricted permissions "
      "\n\tshould be unrestricted" );
   }

   t = dynamic_cast<IsolatedStorageFilePermission^>(isfp0->Union( isfp2 ));
   if ( true == t->IsUnrestricted() )
   {
      Console::WriteLine( "The union of a PermissionState.Unrestricted and a PermissionState.None "
      "\n\tpermission is unrestricted." );
   }
   else
   {
      Console::WriteLine( "Union demo failed because the union of a PermissionState.Unrestricted and a "
      "\n\tPermissionState.None permission should be unrestricted." );
   }

   t = dynamic_cast<IsolatedStorageFilePermission^>(isfp2->Union( isfp3 ));
   if ( nullptr != t )
   {
      Console::WriteLine( "The union of two PermissionState.None permissions is none." );
   }
   else
   {
      Console::WriteLine( "Union failed because the union of two PermissionState.None permissions should not be null." );
      Console::WriteLine( t );
   }
}

private void UnionDemo()
{
    Console.WriteLine("\nUnion demo.");
    IsolatedStorageFilePermission isfp0 = 
        new IsolatedStorageFilePermission(PermissionState.Unrestricted);
    IsolatedStorageFilePermission isfp1 = 
        new IsolatedStorageFilePermission(PermissionState.Unrestricted);
    IsolatedStorageFilePermission isfp2 = 
        new IsolatedStorageFilePermission(PermissionState.None);
    IsolatedStorageFilePermission isfp3 = 
        new IsolatedStorageFilePermission(PermissionState.None);
    IsolatedStorageFilePermission t = 
        ((IsolatedStorageFilePermission)(isfp0.Union(isfp1)));

    if (true == t.IsUnrestricted()) {
        Console.WriteLine("The union of two " 
            + "PermissionState.Unrestricted permissions is unrestricted.");
    }
    else {
        Console.WriteLine(("Union demo failed because the union " 
            + "of two PermissionState.Unrestricted permissions " 
            + "\n\tshould be unrestricted"));
    }
    t = ((IsolatedStorageFilePermission)(isfp0.Union(isfp2)));
    if (true == t.IsUnrestricted()) {
        Console.WriteLine(("The union of a PermissionState.Unrestricted " 
            + "and a PermissionState.None " 
            + "\n\tpermission is unrestricted."));
    }
    else {
        Console.WriteLine(("Union demo failed because the union of a " 
            + "PermissionState.Unrestricted and a " 
            + "\n\tPermissionState.None permission should be "
            + "unrestricted."));
    }
    t = ((IsolatedStorageFilePermission)(isfp2.Union(isfp3)));
    if (null != t) {
        Console.WriteLine("The union of two PermissionState.None " 
            + "permissions is none.");
    }
    else {
        Console.WriteLine("Union failed because the union of two " 
            + "PermissionState.None permissions should not be null.");
        Console.WriteLine(t.ToString());
    }
} //UnionDemo   

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

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