WebPermission.IsSubsetOf Method
Determines whether the current WebPermission is a subset of the specified object.
[Visual Basic] Overrides Public Function IsSubsetOf( _ ByVal target As IPermission _ ) As Boolean Implements IPermission.IsSubsetOf [C#] public override bool IsSubsetOf( IPermission target ); [C++] public: bool IsSubsetOf( IPermission* target ); [JScript] public override function IsSubsetOf( target : IPermission ) : Boolean;
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.
Implements
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentException | the target parameter is not an instance of WebPermission. |
| NotSupportedException | If the current instance contains a Regex-encoded right and there is not exactly same right found in the target instance. |
Remarks
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.
Example
[Visual Basic, C#, C++] The following example uses IsSubsetOf to determine if the access rights found in one instance of WebPermission are found in another instance of WebPermission.
[Visual Basic] ' 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 'myIsSubsetExample [C#] // 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)); [C++] // Create the target permission. WebPermission* targetPermission = new WebPermission(); targetPermission->AddPermission(NetworkAccess::Connect, new Regex(S"www\\.contoso\\.com/Public/.*")); // Create the permission for a URI matching target. WebPermission* connectPermission = new WebPermission(); connectPermission->AddPermission(NetworkAccess::Connect, S"www.contoso.com/Public/default.htm"); //The following statement prints true. Console::WriteLine(S"Is the second URI a subset of the first one?: {0}", __box(connectPermission->IsSubsetOf(targetPermission)));
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard
See Also
WebPermission Class | WebPermission Members | System.Net Namespace