IsSubsetOf Method
Collapse the table of content
Expand the table of content

WebPermission.IsSubsetOf Method

Determines whether the current WebPermission is a subset of the specified object.

Namespace: System.Net
Assembly: System (in system.dll)

public:
virtual bool IsSubsetOf (
	IPermission^ target
) override
public boolean IsSubsetOf (
	IPermission target
)
public override function IsSubsetOf (
	target : IPermission
) : boolean
Not applicable.

Parameters

target

The WebPermission to compare to the current WebPermission.

Return Value

true if the current instance is a subset of the target parameter; otherwise, false. If the target is a null reference (Nothing in Visual Basic), the method returns true for an empty current permission that is not unrestricted and false otherwise.

Exception typeCondition

ArgumentException

The target parameter is not an instance of WebPermission.

NotSupportedException

The current instance contains a Regex-encoded right and there is not exactly the same right found in the target instance.

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. This method overrides IsSubsetOf and is implemented to support the IPermission interface.

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?: " 
    + (System.Boolean)connectPermission.IsSubsetOf(targetPermission));

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft