Freigeben über


IsolatedStorageFilePermission.Intersect-Methode

Erstellt eine Berechtigung als Schnittmenge der aktuellen und der angegebenen Berechtigung und gibt diese zurück.

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

Syntax

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

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

Parameter

  • target
    Eine Berechtigung, deren Schnittmenge mit dem aktuellen Berechtigungsobjekt gebildet wird. Diese muss von demselben Typ wie die aktuelle Berechtigung sein.

Rückgabewert

Eine neue Berechtigung, die die Schnittmenge der aktuellen und der angegebenen Berechtigung darstellt. Diese neue Berechtigung ist NULL (Nothing in Visual Basic), wenn die Schnittmenge leer ist.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

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

Hinweise

Die Schnittmenge zweier Berechtigungen ist eine Berechtigung, die die von beiden Berechtigungen gemeinsam beschriebene Gruppe von Operationen wiedergibt. Eine Anforderung über die Schnittmenge ist nur erfolgreich, wenn sie beide ursprünglichen Berechtigungen erfolgreich durchläuft.

Beispiel

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

Private Sub IntersectDemo()
    Console.WriteLine(ControlChars.Lf + "Intersect 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.Intersect(isfp1), IsolatedStorageFilePermission)
    If True = t.IsUnrestricted() Then
        Console.WriteLine("The intersection of two PermissionState.Unrestricted permissions is unrestricted.")
    Else
        Console.WriteLine(("Intersect demo failed because the intersection of two unrestricted permissions " + ControlChars.Lf + ControlChars.Tab + "should be unrestricted."))
    End If

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


    ' The permission set that comes back from this intersection is null.
    t = CType(isfp2.Intersect(isfp3), IsolatedStorageFilePermission)
    If Nothing Is t Then
        Console.WriteLine("The intersection of two PermissionState.None permissions is null.")
    Else
        Console.WriteLine(("Intersect failed because the intersection of two PermissionState.None permissions " + ControlChars.Lf + ControlChars.Tab + "should be null."))
    End If
End Sub 'IntersectDemo
private void IntersectDemo()
{
    Console.WriteLine("\nIntersect 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.Intersect(isfp1);
    if (true == t.IsUnrestricted())
    {
        Console.WriteLine
            ("The intersection of two PermissionState.Unrestricted permissions is unrestricted.");
    }
    else
    {
        Console.WriteLine
            ("Intersect demo failed because the intersection of two unrestricted permissions " +
            "\n\tshould be unrestricted.");
    }

    t = (IsolatedStorageFilePermission)isfp0.Intersect(isfp2);
    if (false == t.IsUnrestricted())
    {
        Console.WriteLine
            ("The intersection of a PermissionState.Unrestricted and " +
            "\n\tPermissionState.None permission is not unrestricted.");
    }
    else
    {
        Console.WriteLine
            ("Intersect demo failed because the intersection of a unrestricted and " +
            "\n\tnone permission should be none.");
    }


    // The permission set that comes back from this intersection is null.
    t = (IsolatedStorageFilePermission)isfp2.Intersect(isfp3);
    if (null == t)
    {
        Console.WriteLine
            ("The intersection of two PermissionState.None permissions is null.");
    }
    else
    {
        Console.WriteLine
            ("Intersect failed because the intersection of two PermissionState.None permissions " +
            "\n\tshould be null.");
    }

}
void IntersectDemo()
{
   Console::WriteLine( "\nIntersect 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->Intersect( isfp1 ));
   if ( true == t->IsUnrestricted() )
   {
      Console::WriteLine( "The intersection of two PermissionState.Unrestricted permissions is unrestricted." );
   }
   else
   {
      Console::WriteLine( "Intersect demo failed because the intersection of two unrestricted permissions "
      "\n\tshould be unrestricted." );
   }

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

   
   // The permission set that comes back from this intersection is null.
   t = dynamic_cast<IsolatedStorageFilePermission^>(isfp2->Intersect( isfp3 ));
   if ( nullptr == t )
   {
      Console::WriteLine( "The intersection of two PermissionState.None permissions is null." );
   }
   else
   {
      Console::WriteLine( "Intersect failed because the intersection of two PermissionState.None permissions "
      "\n\tshould be null." );
   }
}

private void IntersectDemo()
{
    Console.WriteLine("\nIntersect 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.Intersect(isfp1)));
    if (true == t.IsUnrestricted()) {
        Console.WriteLine("The intersection of two " 
            + "PermissionState.Unrestricted permissions is unrestricted.");
    }
    else {
        Console.WriteLine(("Intersect demo failed because the " 
            + "intersection of two unrestricted permissions " 
            + "\n\tshould be unrestricted."));
    }
    t = ((IsolatedStorageFilePermission)(isfp0.Intersect(isfp2)));
    if (false == t.IsUnrestricted()) {
        Console.WriteLine(("The intersection of a " 
            + "PermissionState.Unrestricted and " 
            + "\n\tPermissionState.None permission is not unrestricted."));
    }
    else {
        Console.WriteLine(("Intersect demo failed because the " 
            + "intersection of a unrestricted and " 
            + "\n\tnone permission should be none."));
    }

    // The permission set that comes back from this intersection is null.
    t = ((IsolatedStorageFilePermission)(isfp2.Intersect(isfp3)));
    if (null == t) {
        Console.WriteLine("The intersection of two " 
            + "PermissionState.None permissions is null.");
    }
    else {
        Console.WriteLine(("Intersect failed because the " 
            + "intersection of two PermissionState.None permissions " 
            + "\n\tshould be null."));
    }
} //IntersectDemo   

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