現在のアクセス許可が、指定したアクセス許可のサブセットかどうかを判断します。
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) ではなく、現在のアクセス許可と同じ型でもありません。 |
解説
現在のアクセス許可で指定される操作の集合が、指定したアクセス許可に完全に含まれる場合、現在のアクセス許可オブジェクトは指定したアクセス許可オブジェクトのサブセットです。
使用例
' IsSubsetOf determines whether the current permission is a subset of the specified permission.
Private Function IsSubsetOfDemo() As Boolean
Dim returnValue As Boolean = True
Dim zone1, zone2 As SecurityZone
Dim zoneIdPerm1, zoneIdPerm2 As ZoneIdentityPermission
Dim zoneGen1 As New zoneGenerator()
Dim zoneGen2 As New zoneGenerator()
zoneGen1.ResetIndex()
While zoneGen1.CreateZone(zoneIdPerm1, zone1)
If zoneIdPerm1 Is Nothing Then
GoTo ContinueWhile1
End If
zoneGen2.ResetIndex()
Console.WriteLine("********************************************************" & ControlChars.Cr)
While zoneGen2.CreateZone(zoneIdPerm2, zone2)
If zoneIdPerm2 Is Nothing Then
GoTo ContinueWhile2
End If
Try
If zoneIdPerm1.IsSubsetOf(zoneIdPerm2) Then
Console.WriteLine((zoneIdPerm1.SecurityZone.ToString() & _
" is a subset of " & zoneIdPerm2.SecurityZone.ToString()))
Else
Console.WriteLine((zoneIdPerm1.SecurityZone.ToString() & _
" is not a subset of " & zoneIdPerm2.SecurityZone.ToString()))
End If
Catch e As Exception
Console.WriteLine(("An exception was thrown for subset :" & _
zoneIdPerm1.ToString() & ControlChars.Cr & zoneIdPerm2.ToString() & _
ControlChars.Cr & e.ToString()))
returnValue = False
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;
SecurityZone zone1,zone2;
ZoneIdentityPermission zoneIdPerm1,zoneIdPerm2;
ZoneGenerator zoneGen1 = new ZoneGenerator();
ZoneGenerator zoneGen2 = new ZoneGenerator();
zoneGen1.ResetIndex();
while(zoneGen1.CreateZone(out zoneIdPerm1, out zone1))
{
if(zoneIdPerm1 == null) continue;
zoneGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
while(zoneGen2.CreateZone(out zoneIdPerm2, out zone2))
{
if(zoneIdPerm2 == null) continue;
try
{
if (zoneIdPerm1.IsSubsetOf(zoneIdPerm2))
{
Console.WriteLine(zoneIdPerm1.SecurityZone + " is a subset of " +
zoneIdPerm2.SecurityZone);
}
else
{
Console.WriteLine(zoneIdPerm1.SecurityZone + " is not a subset of " +
zoneIdPerm2.SecurityZone);
}
}
catch(Exception e)
{
Console.WriteLine("An exception was thrown for subset :" + zoneIdPerm1 + "\n" +
zoneIdPerm2 +"\n" + e);
returnValue=false;
}
}
}
return returnValue;
}
[C++]
// IsSubsetOf determines whether the current permission is a subset of the specified permission.
private:
bool IsSubsetOfDemo() {
bool returnValue = true;
SecurityZone zone1, zone2;
ZoneIdentityPermission* zoneIdPerm1, * zoneIdPerm2;
ZoneGenerator* zoneGen1 = new ZoneGenerator();
ZoneGenerator* zoneGen2 = new ZoneGenerator();
zoneGen1->ResetIndex();
while(zoneGen1->CreateZone(&zoneIdPerm1, &zone1)) {
if (zoneIdPerm1 == 0) continue;
zoneGen2->ResetIndex();
Console::WriteLine(S"********************************************************\n");
while(zoneGen2->CreateZone(&zoneIdPerm2, &zone2)) {
if (zoneIdPerm2 == 0) continue;
try {
if (zoneIdPerm1->IsSubsetOf(zoneIdPerm2)) {
Console::WriteLine(S"{0} is a subset of {1}",
__box(zoneIdPerm1->SecurityZone), __box(zoneIdPerm2->SecurityZone));
} else {
Console::WriteLine(S"{0} is not a subset of {1}",
__box(zoneIdPerm1->SecurityZone), __box(zoneIdPerm2->SecurityZone));
}
} catch (Exception* e) {
Console::WriteLine(S"An exception was thrown for subset : {0}\n{1}\n{2}",
zoneIdPerm1, zoneIdPerm2, e);
returnValue=false;
}
}
}
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 ファミリ
参照
ZoneIdentityPermission クラス | ZoneIdentityPermission メンバ | System.Security.Permissions 名前空間