IPermission.IsSubsetOf(IPermission) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Determina se l'autorizzazione corrente è un subset di quella specificata.
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
Parametri
- target
- IPermission
Autorizzazione da testare per la relazione del subset. Questa autorizzazione deve essere dello stesso tipo di quella corrente.
Restituisce
true
se l'autorizzazione corrente è un subset di quella specificata; in caso contrario, false
.
Eccezioni
Il parametro target
non è null
e non è dello stesso tipo dell'autorizzazione corrente.
Esempio
Nell'esempio di codice seguente viene illustrato l'implementazione del IsSubsetOf metodo. Questo esempio di codice fa parte di un esempio più grande fornito per la IPermission classe.
// 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
Commenti
L'autorizzazione corrente è un subset dell'autorizzazione specificata se l'autorizzazione corrente specifica un set di operazioni interamente contenuto dall'autorizzazione specificata. Ad esempio, un'autorizzazione che rappresenta l'accesso a C:\example.txt è un subset di un'autorizzazione che rappresenta l'accesso a C:\. Se questo metodo restituisce true
, l'autorizzazione corrente non rappresenta più l'accesso alla risorsa protetta rispetto all'autorizzazione specificata.
Per tutte le implementazioni del IsSubsetOf metodo sono necessarie le istruzioni seguenti. X
, Y
e Z
rappresentano IPermission oggetti che non null
sono .
X
. IsSubsetOf(X
) restituiscetrue
.X
. IsSubsetOf(Y
) restituisce lo stesso valore diY
. IsSubsetOf(X
) se e solo seX
eY
rappresentano lo stesso set di autorizzazioni.Se
X
. IsSubsetOf(Y
) eY
. IsSubsetOf(Z
) restituiscetrue
,X
. IsSubsetOf(Z
) restituiscetrue
.
Se X
rappresenta un oggetto vuoto IPermission con uno stato di autorizzazione di None e Y
rappresenta un IPermission oggetto che è null
, X
. IsSubsetOf(Y
) restituisce true
. Se Z
è anche un'autorizzazione vuota, l'operazione X
del set composto . Union(Z). IsSubsetOf(Y) restituisce true
anche perché l'unione di due autorizzazioni vuote è un'autorizzazione vuota.
Si applica a
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per