Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Bestimmt, ob die aktuelle Berechtigung eine Teilmenge der angegebenen Berechtigung ist.
Namespace: System.Net
Assembly: System (in system.dll)
Syntax
'Declaration
Public Overrides Function IsSubsetOf ( _
target As IPermission _
) As Boolean
'Usage
Dim instance As SocketPermission
Dim target As IPermission
Dim returnValue As Boolean
returnValue = instance.IsSubsetOf(target)
public override bool IsSubsetOf (
IPermission target
)
public:
virtual bool IsSubsetOf (
IPermission^ target
) override
public boolean IsSubsetOf (
IPermission target
)
public override function IsSubsetOf (
target : IPermission
) : boolean
Parameter
- target
Eine SocketPermission, die auf die Teilmengenbeziehung überprüft werden soll.
Rückgabewert
Wenn target auf NULL (Nothing in Visual Basic) festgelegt wurde, gibt diese Methode true zurück, wenn die aktuelle Instanz keine Berechtigungen definiert, und andernfalls false. Wenn target nicht NULL (Nothing in Visual Basic) ist, gibt diese Methode true zurück, wenn die aktuelle Instanz eine Teilmenge von target-Berechtigungen definiert, und andernfalls false.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
target ist keine SocketException. |
|
Dem Methodenaufrufer wird keine DnsPermission erteilt. |
Hinweise
Die aktuelle Berechtigung ist eine Teilmenge der angegebenen Berechtigung, wenn die aktuelle Berechtigung eine Gruppe von Operationen angibt, die vollständig in der angegebenen Berechtigung enthalten ist.
Eine Berechtigung, die z. B. Zugriff auf 192.168.1.1:80 darstellt, ist eine Teilmenge einer Berechtigung, die Zugriff auf 192.168.1.1:Any darstellt. Wenn diese Methode true zurückgibt, stellt die aktuelle Berechtigung keine weitergehenden Zugriffsrechte für die geschützte Ressource dar als die angegebene Berechtigung.
Beispiel
Im folgenden Beispiel wird mit der IsSubsetOf-Methode festgelegt, ob eine SocketPermission die Teilmenge einer anderen darstellt.
' Creates a SocketPermission restricting access to and from all URIs.
Dim mySocketPermission1 As New SocketPermission(PermissionState.None)
' The socket to which this permission will apply will allow connections from www.contoso.com.
mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "www.contoso.com", 11000)
' Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com.
Dim mySocketPermission2 As New SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "www.southridgevideo.com", 11002)
' Creates a SocketPermission from the union of two SocketPermissions.
Dim mySocketPermissionUnion As SocketPermission = CType(mySocketPermission1.Union(mySocketPermission2), SocketPermission)
' Checks to see if the union was successfully created by using the IsSubsetOf method.
If mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) And mySocketPermission2.IsSubsetOf(mySocketPermissionUnion) Then
Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2")
' Prints the allowable accept URIs to the console.
Console.WriteLine("This union accepts connections on :")
Dim myEnumerator As IEnumerator = mySocketPermissionUnion.AcceptList
While myEnumerator.MoveNext()
Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString())
End While
Console.WriteLine("This union establishes connections on : ")
' Prints the allowable connect URIs to the console.
Console.WriteLine("This union permits connections to :")
myEnumerator = mySocketPermissionUnion.ConnectList
While myEnumerator.MoveNext()
Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString())
End While
End If
// Creates a SocketPermission restricting access to and from all URIs.
SocketPermission mySocketPermission1 = new SocketPermission(PermissionState.None);
// The socket to which this permission will apply will allow connections from www.contoso.com.
mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "www.contoso.com", 11000);
// Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com.
SocketPermission mySocketPermission2 =
new SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "www.southridgevideo.com", 11002);
// Creates a SocketPermission from the union of two SocketPermissions.
SocketPermission mySocketPermissionUnion =
(SocketPermission)mySocketPermission1.Union(mySocketPermission2);
// Checks to see if the union was successfully created by using the IsSubsetOf method.
if (mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) &&
mySocketPermission2.IsSubsetOf(mySocketPermissionUnion)){
Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2");
// Prints the allowable accept URIs to the console.
Console.WriteLine("This union accepts connections on :");
IEnumerator myEnumerator = mySocketPermissionUnion.AcceptList;
while (myEnumerator.MoveNext()) {
Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString());
}
// Prints the allowable connect URIs to the console.
Console.WriteLine("This union permits connections to :");
myEnumerator = mySocketPermissionUnion.ConnectList;
while (myEnumerator.MoveNext()) {
Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString());
}
}
// Creates a SocketPermission restricting access to and from all URIs.
SocketPermission^ mySocketPermission1 = gcnew SocketPermission( PermissionState::None );
// The socket to which this permission will apply will allow connections from www.contoso.com.
mySocketPermission1->AddPermission( NetworkAccess::Accept, TransportType::Tcp, "www.contoso.com", 11000 );
// Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com.
SocketPermission^ mySocketPermission2 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::Tcp, "www.southridgevideo.com",11002 );
// Creates a SocketPermission from the union of two SocketPermissions.
SocketPermission^ mySocketPermissionUnion =
(SocketPermission^)( mySocketPermission1->Union( mySocketPermission2 ) );
// Checks to see if the union was successfully created by using the IsSubsetOf method.
if ( mySocketPermission1->IsSubsetOf( mySocketPermissionUnion ) &&
mySocketPermission2->IsSubsetOf( mySocketPermissionUnion ) )
{
Console::WriteLine( "This union contains permissions from both mySocketPermission1 and mySocketPermission2" );
// Prints the allowable accept URIs to the console.
Console::WriteLine( "This union accepts connections on :" );
IEnumerator^ myEnumerator = mySocketPermissionUnion->AcceptList;
while ( myEnumerator->MoveNext() )
{
Console::WriteLine( safe_cast<EndpointPermission^>( myEnumerator->Current )->ToString() );
}
// Prints the allowable connect URIs to the console.
Console::WriteLine( "This union permits connections to :" );
myEnumerator = mySocketPermissionUnion->ConnectList;
while ( myEnumerator->MoveNext() )
{
Console::WriteLine( safe_cast<EndpointPermission^>( myEnumerator->Current )->ToString() );
}
}
// Creates a SocketPermission restricting access to and from all URIs.
SocketPermission mySocketPermission1
= new SocketPermission(PermissionState.None);
// The socket to which this permission will apply will allow
// connections from www.contoso.com.
mySocketPermission1.AddPermission(NetworkAccess.Accept,
TransportType.Tcp, "www.contoso.com", 11000);
// Creates a SocketPermission which will allow the target Socket to
// connect with www.southridgevideo.com.
SocketPermission mySocketPermission2
= new SocketPermission(NetworkAccess.Connect,
TransportType.Tcp, "www.southridgevideo.com", 11002);
// Creates a SocketPermission from the union of two SocketPermissions.
SocketPermission mySocketPermissionUnion
= (SocketPermission)mySocketPermission1.Union(mySocketPermission2);
// Checks to see if the union was successfully created by using the
// IsSubsetOf method.
if (mySocketPermission1.IsSubsetOf(mySocketPermissionUnion)
&& mySocketPermission2.IsSubsetOf(mySocketPermissionUnion)) {
Console.WriteLine("This union contains permissions from both " + "mySocketPermission1 and mySocketPermission2");
// Prints the allowable accept URIs to the console.
Console.WriteLine("This union accepts connections on :");
IEnumerator myEnumerator = mySocketPermissionUnion.
get_AcceptList();
while (myEnumerator.MoveNext()) {
Console.WriteLine(((EndpointPermission)myEnumerator.
get_Current()).ToString());
}
// Prints the allowable connect URIs to the console.
Console.WriteLine("This union permits connections to :");
myEnumerator = mySocketPermissionUnion.get_ConnectList();
while (myEnumerator.MoveNext()) {
Console.WriteLine(((EndpointPermission)myEnumerator.
get_Current()).ToString());
}
}
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
SocketPermission-Klasse
SocketPermission-Member
System.Net-Namespace