IsolatedStorageFilePermission.IsSubsetOf-Methode
Bestimmt, ob die aktuelle Berechtigung eine Teilmenge der angegebenen Berechtigung ist.
Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Overrides Function IsSubsetOf ( _
target As IPermission _
) As Boolean
'Usage
Dim instance As IsolatedStorageFilePermission
Dim target As IPermission
Dim returnValue As Boolean
returnValue = instance.IsSubsetOf(target)
public override bool IsSubsetOf (
IPermission target
)
public:
virtual bool IsSubsetOf (
IPermission^ target
) override
public boolean IsSubsetOf (
IPermission target
)
public override function IsSubsetOf (
target : IPermission
) : boolean
Parameter
- target
Eine Berechtigung, für die geprüft werden soll, ob sie eine Teilmenge einer anderen Berechtigung ist. Diese Berechtigung muss von demselben Typ wie die aktuelle Berechtigung sein.
Rückgabewert
true, wenn die aktuelle Berechtigung eine Teilmenge der angegebenen Berechtigung ist, andernfalls false.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der target-Parameter ist nicht NULL (Nothing in Visual Basic) und nicht von demselben Typ wie die aktuelle Berechtigung. |
Hinweise
Die aktuelle Berechtigung ist eine Teilmenge der angegebenen Berechtigung, wenn die aktuelle Berechtigung eine Gruppe von Operationen angibt, die vollständig in der angegebenen Berechtigung enthalten ist. Beispielsweise ist eine Berechtigung, die den Zugriff auf C:\beispiel.txt darstellt, eine Teilmenge einer Berechtigung, die den Zugriff auf C:\ darstellt. Wenn diese Methode true zurückgibt, stellt die aktuelle Berechtigung keine weitergehenden Zugriffsrechte für die geschützte Ressource dar als die angegebene Berechtigung.
Beispiel
Im folgenden Code wird die Verwendung der IsSubsetOf-Methode veranschaulicht. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels für die IsolatedStorageFilePermission-Klasse.
Private Sub IsSubsetOfDemo()
Console.WriteLine(ControlChars.Lf + "IsSubsetOf demo.")
Dim isfp0 As New IsolatedStorageFilePermission(PermissionState.None)
Dim isfp1 As New IsolatedStorageFilePermission(PermissionState.None)
Dim isfp2 As New IsolatedStorageFilePermission(PermissionState.Unrestricted)
Dim isfp3 As New IsolatedStorageFilePermission(PermissionState.Unrestricted)
If isfp0.IsSubsetOf(isfp1) Then
Console.WriteLine("PermissionState.None is a subset of PermissionState.None.")
Else
Console.WriteLine("IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.None")
End If
If isfp0.IsSubsetOf(isfp2) Then
Console.WriteLine("PermissionState.None is a subset of PermissionState.Unrestricted.")
Else
Console.WriteLine("IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.Unrestricted")
End If
If Not isfp2.IsSubsetOf(isfp0) Then
Console.WriteLine("PermissionState.Unrestricted is not a subset of PermissionState.None.")
Else
Console.WriteLine(("IsSubsetOfDemo failed: PermissionState.Unrestricted should not be a subset " + ControlChars.Lf + ControlChars.Tab + "of PermissionState.None"))
End If
If isfp2.IsSubsetOf(isfp3) Then
Console.WriteLine("PermissionState.Unrestricted is a subset of PermissionState.Unrestricted.")
Else
Console.WriteLine(("IsSubsetOfDemo failed: Permissionstate.Unrestricted should be a subset of " + ControlChars.Lf + ControlChars.Tab + "PermissionState.Unrestricted"))
End If
End Sub 'IsSubsetOfDemo
private void IsSubsetOfDemo()
{
Console.WriteLine("\nIsSubsetOf demo.");
IsolatedStorageFilePermission isfp0 = new IsolatedStorageFilePermission(PermissionState.None);
IsolatedStorageFilePermission isfp1 = new IsolatedStorageFilePermission(PermissionState.None);
IsolatedStorageFilePermission isfp2 = new IsolatedStorageFilePermission(PermissionState.Unrestricted);
IsolatedStorageFilePermission isfp3 = new IsolatedStorageFilePermission(PermissionState.Unrestricted);
if (isfp0.IsSubsetOf(isfp1))
{
Console.WriteLine
("PermissionState.None is a subset of PermissionState.None.");
}
else
{
Console.WriteLine
("IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.None");
}
if (isfp0.IsSubsetOf(isfp2))
{
Console.WriteLine
("PermissionState.None is a subset of PermissionState.Unrestricted.");
}
else
{
Console.WriteLine
("IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.Unrestricted");
}
if (!isfp2.IsSubsetOf(isfp0))
{
Console.WriteLine
("PermissionState.Unrestricted is not a subset of PermissionState.None.");
}
else
{
Console.WriteLine
("IsSubsetOfDemo failed: PermissionState.Unrestricted should not be a subset " +
"\n\tof PermissionState.None");
}
if (isfp2.IsSubsetOf(isfp3))
{
Console.WriteLine
("PermissionState.Unrestricted is a subset of PermissionState.Unrestricted.");
}
else
{
Console.WriteLine
("IsSubsetOfDemo failed: Permissionstate.Unrestricted should be a subset of " +
"\n\tPermissionState.Unrestricted");
}
}
void IsSubsetOfDemo()
{
Console::WriteLine( "\nIsSubsetOf demo." );
IsolatedStorageFilePermission^ isfp0 = gcnew IsolatedStorageFilePermission( PermissionState::None );
IsolatedStorageFilePermission^ isfp1 = gcnew IsolatedStorageFilePermission( PermissionState::None );
IsolatedStorageFilePermission^ isfp2 = gcnew IsolatedStorageFilePermission( PermissionState::Unrestricted );
IsolatedStorageFilePermission^ isfp3 = gcnew IsolatedStorageFilePermission( PermissionState::Unrestricted );
if ( isfp0->IsSubsetOf( isfp1 ) )
{
Console::WriteLine( "PermissionState.None is a subset of PermissionState.None." );
}
else
{
Console::WriteLine( "IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.None" );
}
if ( isfp0->IsSubsetOf( isfp2 ) )
{
Console::WriteLine( "PermissionState.None is a subset of PermissionState.Unrestricted." );
}
else
{
Console::WriteLine( "IsSubsetOfDemo failed: PermissionState.None should be a subset of PermissionState.Unrestricted" );
}
if ( !isfp2->IsSubsetOf( isfp0 ) )
{
Console::WriteLine( "PermissionState.Unrestricted is not a subset of PermissionState.None." );
}
else
{
Console::WriteLine( "IsSubsetOfDemo failed: PermissionState.Unrestricted should not be a subset "
"\n\tof PermissionState.None" );
}
if ( isfp2->IsSubsetOf( isfp3 ) )
{
Console::WriteLine( "PermissionState.Unrestricted is a subset of PermissionState.Unrestricted." );
}
else
{
Console::WriteLine( "IsSubsetOfDemo failed: Permissionstate.Unrestricted should be a subset of "
"\n\tPermissionState.Unrestricted" );
}
}
private void IsSubsetOfDemo()
{
Console.WriteLine("\nIsSubsetOf demo.");
IsolatedStorageFilePermission isfp0 =
new IsolatedStorageFilePermission(PermissionState.None);
IsolatedStorageFilePermission isfp1 =
new IsolatedStorageFilePermission(PermissionState.None);
IsolatedStorageFilePermission isfp2 =
new IsolatedStorageFilePermission(PermissionState.Unrestricted);
IsolatedStorageFilePermission isfp3 =
new IsolatedStorageFilePermission(PermissionState.Unrestricted);
if (isfp0.IsSubsetOf(isfp1)) {
Console.WriteLine("PermissionState.None is a subset of "
+ "PermissionState.None.");
}
else {
Console.WriteLine("IsSubsetOfDemo failed: PermissionState.None "
+ "should be a subset of PermissionState.None");
}
if (isfp0.IsSubsetOf(isfp2)) {
Console.WriteLine("PermissionState.None is a subset of "
+ "PermissionState.Unrestricted.");
}
else {
Console.WriteLine("IsSubsetOfDemo failed: PermissionState.None "
+ "should be a subset of PermissionState.Unrestricted");
}
if (!(isfp2.IsSubsetOf(isfp0))) {
Console.WriteLine("PermissionState.Unrestricted is not "
+ "a subset of PermissionState.None.");
}
else {
Console.WriteLine(("IsSubsetOfDemo failed: PermissionState."
+ "Unrestricted should not be a subset "
+ "\n\tof PermissionState.None"));
}
if (isfp2.IsSubsetOf(isfp3)) {
Console.WriteLine("PermissionState.Unrestricted is a "
+ "subset of PermissionState.Unrestricted.");
}
else {
Console.WriteLine(("IsSubsetOfDemo failed: "
+ "Permissionstate.Unrestricted should be a subset of "
+ "\n\tPermissionState.Unrestricted"));
}
} //IsSubsetOfDemo
Plattformen
Windows 98, Windows 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
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
IsolatedStorageFilePermission-Klasse
IsolatedStorageFilePermission-Member
System.Security.Permissions-Namespace