IPermission.IsSubsetOf(IPermission) Método

Definición

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

public:
 bool IsSubsetOf(System::Security::IPermission ^ target);
public bool IsSubsetOf (System.Security.IPermission target);
public bool IsSubsetOf (System.Security.IPermission? target);
abstract member IsSubsetOf : System.Security.IPermission -> bool
Public Function IsSubsetOf (target As IPermission) As Boolean

Parámetros

target
IPermission

Permiso que se va a probar para la relación de 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.

Excepciones

El parámetro target no es null y no es del mismo tipo que el permiso actual.

Ejemplos

En el ejemplo de código siguiente se muestra cómo implementar el IsSubsetOf método . Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase IPermission.

    // Called by the Demand method: returns true 
    // if 'this' is a subset of 'target'.
public:
    virtual bool IsSubsetOf(IPermission^ target) override
    {
        // If 'target' is null and this permission allows nothing, 
        // return true.
        if (target == nullptr)
        {
            return (int)stateFlags == 0;
        }

        // Both objects must be the same type.
        SoundPermission^ soundPerm = VerifyTypeMatch(target);

        // Return true if the permissions of 'this' 
        // is a subset of 'target'.
        return stateFlags <= soundPerm->stateFlags;
    }
// Called by the Demand method: returns true if 'this' is a subset of 'target'.
public override Boolean IsSubsetOf(IPermission target)
{
    // If 'target' is null and this permission allows nothing, return true.
    if (target == null) return m_flags == 0;

    // Both objects must be the same type.
    SoundPermission soundPerm = VerifyTypeMatch(target);

    // Return true if the permissions of 'this' is a subset of 'target'.
    return m_flags <= soundPerm.m_flags;
}
' Called by the Demand method: returns true if 'this' is a subset of 'target'.
Public Overrides Function IsSubsetOf(ByVal target As IPermission) As [Boolean]
    ' If 'target' is null and this permission allows nothing, return true.
    If target Is Nothing Then
        Return m_flags = 0
    End If
    ' Both objects must be the same type.
    Dim soundPerm As SoundPermission = VerifyTypeMatch(target)

    ' Return true if the permissions of 'this' is a subset of 'target'.
    Return m_flags <= soundPerm.m_flags

End Function 'IsSubsetOf

Comentarios

El permiso actual es un subconjunto del permiso especificado si el permiso actual especifica un conjunto de operaciones que contiene totalmente el permiso especificado. Por ejemplo, un permiso que representa el acceso a C:\example.txt es un subconjunto de un permiso que representa el acceso a C:\. Si este método devuelve true, el permiso actual no representa más acceso al recurso protegido que el permiso especificado.

Las siguientes instrucciones deben ser true para todas las implementaciones del IsSubsetOf método . X, Yy Z representan IPermission objetos que no nullson .

  • X. IsSubsetOf(X) devuelve true.

  • X. IsSubsetOf(Y) devuelve el mismo valor que Y. IsSubsetOf(X) si y solo si X y Y representan el mismo conjunto de permisos.

  • Si Xes . IsSubsetOf(Y) y Y. IsSubsetOf(Z) devuelven true, X. IsSubsetOf(Z) devuelve true.

Si X representa un objeto vacío IPermission con un estado de permiso de None y Y representa un IPermission objeto que es null, X. IsSubsetOf(Y) devuelve true. Si Z también es un permiso vacío, la operación Xde conjunto compuesto . Union(Z). IsSubsetOf(Y) también devuelve true porque la unión de dos permisos vacíos es un permiso vacío.

Se aplica a