UIPermission.Intersect(IPermission) Metoda

Definicja

Tworzy i zwraca uprawnienie, które jest skrzyżowaniem bieżącego uprawnienia i określonego uprawnienia.

public:
 override System::Security::IPermission ^ Intersect(System::Security::IPermission ^ target);
public override System.Security.IPermission Intersect (System.Security.IPermission target);
override this.Intersect : System.Security.IPermission -> System.Security.IPermission
Public Overrides Function Intersect (target As IPermission) As IPermission

Parametry

target
IPermission

Uprawnienie do przecinania się z bieżącym uprawnieniem. Musi to być ten sam typ co bieżące uprawnienie.

Zwraca

IPermission

Nowe uprawnienie reprezentujące część wspólną bieżącego uprawnienia i określone uprawnienie. To nowe uprawnienie jest null , jeśli skrzyżowanie jest puste.

Wyjątki

Parametr target nie null jest i nie jest tego samego typu co bieżące uprawnienie.

Przykłady

Poniższy przykład kodu przedstawia zachowanie Intersect metody . Ten przykład jest częścią większego przykładu udostępnionego UIPermission dla klasy .

Uwaga

Przykładowy kod jest przeznaczony do pokazania zachowania metody, a nie do zademonstrowania jej użycia. Ogólnie rzecz biorąc, metody klas uprawnień są używane przez infrastrukturę zabezpieczeń; nie są one zwykle używane w aplikacjach.

// Intersect creates and returns a new permission that is the intersection of the
// current permission and the permission specified.
void IntersectDemo()
{
    Console::WriteLine("\n**********************  Intersect() Demo ***********************\n");
    UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows,UIPermissionClipboard::OwnClipboard);
    UIPermission ^ uiPerm2 = gcnew UIPermission(UIPermissionWindow::SafeSubWindows,UIPermissionClipboard::NoClipboard);
    UIPermission ^ p3 = (UIPermission^)uiPerm1->Intersect(uiPerm2);

        Console::WriteLine("   The intersection of {0} and \n\t{1} = {2} ", uiPerm1->Window,
                               uiPerm1->Window, (nullptr != p3)?p3->Window.ToString():"null");

        Console::WriteLine("   The intersection of " + uiPerm1->Clipboard.ToString() + " and \n\t" +
                uiPerm2->Clipboard.ToString() + " is " + p3->Clipboard.ToString());
}
// Intersect creates and returns a new permission that is the intersection of the
// current permission and the permission specified.
private static void IntersectDemo()
{
    UIPermission uiPerm1 = new UIPermission(UIPermissionWindow.SafeTopLevelWindows, UIPermissionClipboard.OwnClipboard);
    UIPermission uiPerm2 = new UIPermission(UIPermissionWindow.SafeSubWindows, UIPermissionClipboard.NoClipboard);
    UIPermission p3 = (UIPermission)uiPerm1.Intersect(uiPerm2);

    Console.WriteLine("The intersection of " + uiPerm1.Window.ToString() + " and \n\t" +
        uiPerm2.Window.ToString() + " is " + p3.Window.ToString() + "\n");
    Console.WriteLine("The intersection of " + uiPerm1.Clipboard.ToString() + " and \n\t" +
            uiPerm2.Clipboard.ToString() + " is " + p3.Clipboard.ToString() + "\n");
}
' Intersect creates and returns a new permission that is the intersection of the
' current permission and the permission specified.
Private Shared Sub IntersectDemo()
    Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows, UIPermissionClipboard.OwnClipboard)
    Dim uiPerm2 As New UIPermission(UIPermissionWindow.SafeSubWindows, UIPermissionClipboard.NoClipboard)
    Dim p3 As UIPermission = CType(uiPerm1.Intersect(uiPerm2), UIPermission)

    Console.WriteLine("The intersection of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is " + p3.Window.ToString() + vbLf)
    Console.WriteLine("The intersection of " + uiPerm1.Clipboard.ToString() + " and " + vbLf + vbTab + uiPerm2.Clipboard.ToString() + " is " + p3.Clipboard.ToString() + vbLf)

End Sub

Uwagi

Przecięcie dwóch uprawnień to uprawnienie, które opisuje zestaw operacji, które opisują wspólne. W szczególności reprezentuje najmniej permissywne wartości UIPermissionWindow i UIPermissionClipboard z tych w bieżącym uprawnieniem i określonym uprawnieniem.

Dotyczy