現在のアクセス許可が、指定したアクセス許可のサブセットかどうかを判断します。
Overrides Public Function IsSubsetOf( _
ByVal target As IPermission _) As Boolean Implements IPermission.IsSubsetOf
[C#]
public override bool IsSubsetOf(IPermissiontarget);
[C++]
public: bool IsSubsetOf(IPermission* target);
[JScript]
public override function IsSubsetOf(
target : IPermission) : Boolean;
パラメータ
- target
サブセットの関係を調べる対象のアクセス許可。このアクセス許可は、現在のアクセス許可と同じ型である必要があります。
戻り値
現在のアクセス許可が、指定したアクセス許可のサブセットである場合は true 。それ以外の場合は false 。
実装
例外
例外の種類 | 条件 |
---|---|
ArgumentException | target パラメータが null 参照 (Visual Basic では Nothing) ではなく、現在のアクセス許可と同じ型でもありません。 |
解説
現在のアクセス許可で指定されているアクセス権が、指定したアクセス許可に完全に含まれる URL へのアクセス権である場合、現在のアクセス許可は指定したアクセス許可のサブセットです。たとえば、https://www.fourthcoffee.com/process/grind.htm へのアクセス権を表すアクセス許可は、https://www.fourthcoffee.com/* へのアクセス権を表すアクセス許可のサブセットです。このメソッドが true を返す場合、現在のアクセス許可は、保護されたリソースに対するアクセス権を指定したアクセス許可と同じにしか表しません。
現在のアクセス許可が、指定したアクセス許可と等しい場合、またはいずれかアクセス許可がワイルドカード演算子 ("*") を使用している場合、 UrlIdentityPermission は set 操作 (IsSubsetOf 、 Intersect 、および Union) だけをサポートします。
使用例
' IsSubsetOf determines whether the current permission is a subset of the specified permission.
Private Function IsSubsetOfDemo() As Boolean
Dim returnValue As Boolean = True
Dim url1, url2 As String
Dim urlIdPerm1, urlIdPerm2 As UrlIdentityPermission
Dim urlGen1 As New UrlGenerator()
Dim urlGen2 As New UrlGenerator()
urlGen1.ResetIndex()
While urlGen1.CreateUrl(urlIdPerm1, url1)
If urlIdPerm1 Is Nothing Then
GoTo ContinueWhile1
End If
urlGen2.ResetIndex()
Console.WriteLine("********************************************************\n")
While urlGen2.CreateUrl(urlIdPerm2, url2)
Dim firstPermission As String = IIf(url1 = "" Or url1 Is Nothing, "null", url1)
Dim secondPermission As String = IIf(url2 = "" Or url2 Is Nothing, "null", url2)
If urlIdPerm2 Is Nothing Then
GoTo ContinueWhile2
End If
Try
If urlIdPerm1.IsSubsetOf(urlIdPerm2) Then
Console.WriteLine(firstPermission & ControlChars.Lf & " is a subset of " & secondPermission & ControlChars.Lf)
Else
Console.WriteLine(firstPermission & ControlChars.Lf & " is not a subset of " & secondPermission & ControlChars.Lf)
End If
Catch e As Exception
Console.WriteLine(IIf("An exception was thrown for subset :" & url1 = "", "null.", IIf(url1 & ControlChars.Lf & url2 = "", "null.", url2 & ControlChars.Lf & e.ToString())))
End Try
ContinueWhile2:
End While
ContinueWhile1:
End While
Return returnValue
End Function 'IsSubsetOfDemo
[C#]
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private bool IsSubsetOfDemo()
{
bool returnValue = true;
string url1,url2;
UrlIdentityPermission urlIdPerm1,urlIdPerm2;
UrlGenerator urlGen1 = new UrlGenerator();
UrlGenerator urlGen2 = new UrlGenerator();
urlGen1.ResetIndex();
while(urlGen1.CreateUrl(out urlIdPerm1, out url1))
{
if(urlIdPerm1 == null) continue;
urlGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
while(urlGen2.CreateUrl(out urlIdPerm2, out url2))
{
string firstPermission = url1 == "" | url1 == null ? "null" : url1 ;
string secondPermission = url2 == "" | url2 == null ? "null" : url2;
if(urlIdPerm2 == null) continue;
try
{
if (urlIdPerm1.IsSubsetOf(urlIdPerm2))
{
Console.WriteLine(firstPermission +"\n is a subset of "
+ secondPermission + "\n");
}
else
{
Console.WriteLine(firstPermission +"\n is not a subset of "
+ secondPermission + "\n");
}
}
catch(Exception e)
{
Console.WriteLine("An exception was thrown for subset :"
+ url1 == "" ? "null." : url1 + "\n" + url2 == "" ? "null." : url2 +"\n" + e);
}
}
}
return returnValue;
}
[C++]
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private:
bool IsSubsetOfDemo() {
bool returnValue = true;
String* url1, *url2;
UrlIdentityPermission* urlIdPerm1, *urlIdPerm2;
UrlGenerator* urlGen1 = new UrlGenerator();
UrlGenerator* urlGen2 = new UrlGenerator();
urlGen1->ResetIndex();
while(urlGen1->CreateUrl(&urlIdPerm1, &url1)) {
if (urlIdPerm1 == 0) continue;
urlGen2->ResetIndex();
Console::WriteLine(S"********************************************************\n");
while(urlGen2->CreateUrl(&urlIdPerm2, &url2)) {
String* firstPermission = url1->Equals(S"") || url1 == 0 ? S"null" : url1 ;
String* secondPermission = url2->Equals(S"") || url2 == 0 ? S"null" : url2;
if (urlIdPerm2 == 0) continue;
try {
if (urlIdPerm1->IsSubsetOf(urlIdPerm2)) {
Console::WriteLine(S"{0}\n is a subset of {1}\n",
firstPermission, secondPermission);
} else {
Console::WriteLine(S"{0}\n is not a subset of {1}\n",
firstPermission, secondPermission);
}
} catch (Exception* e) {
Console::WriteLine(S"An exception was thrown for subset : {0}\n{1}\n{2}",
url1->Equals(S"") ? S"0." : url1, url2->Equals(S"") ? S"0." : url2, e);
}
}
}
return returnValue;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
UrlIdentityPermission クラス | UrlIdentityPermission メンバ | System.Security.Permissions 名前空間