WebPermission.IsSubsetOf(IPermission) Metodo

Definizione

Determina se la WebPermission corrente è un sottoinsieme dell'oggetto specificato.Determines whether the current WebPermission is a subset of the specified object.

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

Parametri

target
IPermission

L'oggetto WebPermission da confrontare con l'oggetto WebPermission corrente.The WebPermission to compare to the current WebPermission.

Restituisce

Boolean

true se l'istanza corrente è un sottoinsieme del parametro target. In caso contrario, false.true if the current instance is a subset of the target parameter; otherwise, false. Se la destinazione è null, il metodo restituirà true per un'autorizzazione corrente vuota con restrizioni e false in caso contrario.If the target is null, the method returns true for an empty current permission that is not unrestricted and false otherwise.

Eccezioni

Il parametro di destinazione non è un'istanza di WebPermission.The target parameter is not an instance of WebPermission.

Nell'istanza corrente è contenuto un diritto codificato Regex e non esiste un diritto che corrisponde in modo esatto all'istanza di destinazione.The current instance contains a Regex-encoded right and there is not exactly the same right found in the target instance.

Esempio

Nell'esempio seguente viene utilizzato IsSubsetOf per determinare se i diritti di accesso presenti in un'istanza di WebPermission si trovano in un'altra istanza di WebPermission.The following example uses IsSubsetOf to determine whether the access rights found in one instance of WebPermission are found in another instance of WebPermission.

// Create the target permission.
WebPermission^ targetPermission = gcnew WebPermission;
targetPermission->AddPermission( NetworkAccess::Connect, gcnew Regex( "www\\.contoso\\.com/Public/.*" ) );

// Create the permission for a URI matching target.
WebPermission^ connectPermission = gcnew WebPermission;
connectPermission->AddPermission( NetworkAccess::Connect, "www.contoso.com/Public/default.htm" );

//The following statement prints true.
Console::WriteLine( "Is the second URI a subset of the first one?: {0}", connectPermission->IsSubsetOf( targetPermission ) );

// Create the target permission.
WebPermission targetPermission = new WebPermission();
targetPermission.AddPermission(NetworkAccess.Connect, new Regex("www\\.contoso\\.com/Public/.*"));

// Create the permission for a URI matching target.
WebPermission connectPermission = new WebPermission();
connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm");

//The following statement prints true.
Console.WriteLine("Is the second URI a subset of the first one?: " + connectPermission.IsSubsetOf(targetPermission));

   ' Create the target permission.
   Dim targetPermission As New WebPermission()
   targetPermission.AddPermission(NetworkAccess.Connect, New Regex("www\.contoso\.com/Public/.*"))
   
   ' Create the permission for a URI matching target.
   Dim connectPermission As New WebPermission()
   connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm")
   
   'The following statement prints true.
   Console.WriteLine(("Is the second URI a subset of the first one?: " & connectPermission.IsSubsetOf(targetPermission)))
End Sub

Commenti

Se il WebPermission corrente specifica un set di risorse associate interamente contenuto nel parametro target, il WebPermission corrente è un subset di target.If the current WebPermission specifies a set of associated resources that is wholly contained by the target parameter, then the current WebPermission is a subset of target. Questo metodo esegue l'override di IsSubsetOf e viene implementato per supportare l'interfaccia IPermission.This method overrides IsSubsetOf and is implemented to support the IPermission interface.

Si applica a