Compartir a través de


NetworkInformationPermission.IsSubsetOf(IPermission) Método

Definición

Determina si el permiso actual es un subconjunto del permiso especificado.

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

Parámetros

target
IPermission

Interfaz IPermission que se va a comprobar para determinar la relación del subconjunto. Este permiso debe ser del mismo tipo que el permiso actual.

Devoluciones

true si el permiso actual es un subconjunto del permiso especificado; si no, false.

Ejemplos

En el ejemplo de código siguiente se muestra la relación de subconjunto entre dos permisos.

System::Net::NetworkInformation::NetworkInformationPermission^ unrestricted = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::Unrestricted );

Console::WriteLine( L"Is unrestricted? {0}", unrestricted->IsUnrestricted() );

System::Net::NetworkInformation::NetworkInformationPermission^ read = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read );

System::Net::NetworkInformation::NetworkInformationPermission^ copyPermission = dynamic_cast<System::Net::NetworkInformation::NetworkInformationPermission^>(read->Copy());

System::Net::NetworkInformation::NetworkInformationPermission^ unionPermission = dynamic_cast<System::Net::NetworkInformation::NetworkInformationPermission^>(read->Union( unrestricted ));
Console::WriteLine( L"Is subset?{0}", read->IsSubsetOf( unionPermission ) );
System.Net.NetworkInformation.NetworkInformationPermission unrestricted =
    new System.Net.NetworkInformation.NetworkInformationPermission(
        System.Security.Permissions.PermissionState.Unrestricted);

Console.WriteLine("Is unrestricted? " + unrestricted.IsUnrestricted());

System.Net.NetworkInformation.NetworkInformationPermission read =
    new System.Net.NetworkInformation.NetworkInformationPermission(
        System.Net.NetworkInformation.NetworkInformationAccess.Read);
System.Net.NetworkInformation.NetworkInformationPermission copyPermission =
   (System.Net.NetworkInformation.NetworkInformationPermission) read.Copy();
System.Net.NetworkInformation.NetworkInformationPermission unionPermission =
   (System.Net.NetworkInformation.NetworkInformationPermission) read.Union(unrestricted);
Console.WriteLine("Is subset?" + read.IsSubsetOf(unionPermission));
Dim unrestricted As New System.Net.NetworkInformation.NetworkInformationPermission( _
    System.Security.Permissions.PermissionState.Unrestricted)
Console.WriteLine("Is unrestricted? " + unrestricted.IsUnrestricted().ToString())
Dim read As New System.Net.NetworkInformation.NetworkInformationPermission( _ 
    System.Net.NetworkInformation.NetworkInformationAccess.Read)
Dim copyPermission As System.Net.NetworkInformation.NetworkInformationPermission = _
    CType(read.Copy(), System.Net.NetworkInformation.NetworkInformationPermission)
Dim unionPermission As System.Net.NetworkInformation.NetworkInformationPermission = _
    CType(read.Union(unrestricted), System.Net.NetworkInformation.NetworkInformationPermission)
Console.WriteLine("Is subset?" + read.IsSubsetOf(unionPermission).ToString())

Comentarios

El permiso actual es un subconjunto del permiso especificado si el permiso actual especifica un estado que está totalmente contenido en el permiso especificado. Si este método devuelve true, el permiso actual no representa más acceso al recurso protegido que el permiso especificado.

Se aplica a