WebPermission.IsSubsetOf(IPermission) 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷目前 WebPermission 是否為指定物件的子集。
public:
override bool IsSubsetOf(System::Security::IPermission ^ target);
C#
public override bool IsSubsetOf(System.Security.IPermission target);
override this.IsSubsetOf : System.Security.IPermission -> bool
Public Overrides Function IsSubsetOf (target As IPermission) As Boolean
- target
- IPermission
要與目前 WebPermission 比較的 WebPermission。
如果目前的執行個體是 target
參數的子集,則為 true
,否則為 false
。 如果目標為 null
,則方法會傳回 true
,表示目前為空的不受限制的使用權限,否則傳回 false
。
目標參數不是 WebPermission 的執行個體。
目前執行個體含有 Regex 編碼權限,且在目標執行個體中找不到完全相同的權限。
下列範例會使用 IsSubsetOf 來判斷某個 實例 WebPermission 中找到的訪問許可權是否在另一個 實例 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 ) );
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));
' 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
如果目前 WebPermission 指定參數完全包含 target
的一組相關聯資源,則目前的 WebPermission 是的 target
子集。 這個方法會 IsSubsetOf 覆寫 並實作以支援 IPermission 介面。
產品 | 版本 |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |