ZoneIdentityPermission.FromXml-Methode
Rekonstruiert aus einer XML-Codierung eine Berechtigung mit einem angegebenen Zustand.
Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Overrides Sub FromXml ( _
esd As SecurityElement _
)
'Usage
Dim instance As ZoneIdentityPermission
Dim esd As SecurityElement
instance.FromXml(esd)
public override void FromXml (
SecurityElement esd
)
public:
virtual void FromXml (
SecurityElement^ esd
) override
public void FromXml (
SecurityElement esd
)
public override function FromXml (
esd : SecurityElement
)
Parameter
- esd
Die XML-Codierung, die zum Wiederherstellen der Berechtigung verwendet werden soll.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der esd-Parameter ist NULL (Nothing in Visual Basic). |
|
Der esd-Parameter ist kein gültiges Berechtigungselement. – oder – Die Versionsnummer des esd-Parameters ist ungültig. |
Beispiel
' ToXml creates an XML encoding of the permission and its current state;
' FromXml reconstructs a permission with the specified state from the XML encoding.
Private Function ToFromXmlDemo() As Boolean
Dim returnValue As Boolean = True
Dim zone1 As SecurityZone
Dim zoneIdPerm1, zoneIdPerm2 As ZoneIdentityPermission
Dim zoneGen1 As New ZoneGenerator()
Dim zoneGen2 As New ZoneGenerator()
zoneGen1.ResetIndex()
While zoneGen1.CreateZone(zone1)
zoneIdPerm1 = New ZoneIdentityPermission(zone1)
Console.WriteLine("********************************************************" & ControlChars.Cr)
zoneGen2.ResetIndex()
Try
zoneIdPerm2 = New ZoneIdentityPermission(PermissionState.None)
zoneIdPerm2.FromXml(zoneIdPerm1.ToXml())
Console.WriteLine(("Result of ToFromXml = " & zoneIdPerm2.ToString()))
Catch e As Exception
Console.WriteLine(("ToFromXml failed :" & zoneIdPerm1.ToString() & e.ToString()))
GoTo ContinueWhile1
End Try
ContinueWhile1:
End While
Return returnValue
End Function 'ToFromXmlDemo
// ToXml creates an XML encoding of the permission and its current state;
// FromXml reconstructs a permission with the specified state from the XML encoding.
private bool ToFromXmlDemo()
{
bool returnValue = true;
SecurityZone zone1;
ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;
ZoneGenerator zoneGen1 = new ZoneGenerator();
ZoneGenerator zoneGen2 = new ZoneGenerator();
zoneGen1.ResetIndex();
while (zoneGen1.CreateZone(out zone1))
{
zoneIdPerm1 = new ZoneIdentityPermission( zone1);
Console.WriteLine("********************************************************\n");
zoneGen2.ResetIndex();
try
{
zoneIdPerm2 = new ZoneIdentityPermission(PermissionState.None);
zoneIdPerm2.FromXml(zoneIdPerm1.ToXml());
Console.WriteLine("Result of ToFromXml = " +
zoneIdPerm2.ToString());
}
catch (Exception e)
{
Console.WriteLine("ToFromXml failed :" + zoneIdPerm1.ToString() + e);
continue;
}
}
return returnValue;
}
// ToXml creates an XML encoding of the permission and its current state;
// FromXml reconstructs a permission with the specified state from the XML encoding.
bool ToFromXmlDemo()
{
bool returnValue = true;
SecurityZone zone1;
ZoneIdentityPermission^ zoneIdPerm1;
ZoneIdentityPermission^ zoneIdPerm2;
ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
zoneGen1->ResetIndex();
while ( zoneGen1->CreateZone( &zone1 ) )
{
zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
Console::WriteLine( "********************************************************\n" );
zoneGen2->ResetIndex();
try
{
zoneIdPerm2 = gcnew ZoneIdentityPermission( PermissionState::None );
zoneIdPerm2->FromXml( zoneIdPerm1->ToXml() );
Console::WriteLine( "Result of ToFromXml = {0}", zoneIdPerm2 );
}
catch ( Exception^ e )
{
Console::WriteLine( "ToFromXml failed : {0}{1}", zoneIdPerm1, e );
continue;
}
}
return returnValue;
}
public:
// ToXml creates an XML encoding of the permission and its current state;
// FromXml reconstructs a permission with the specified
// state from the XML encoding.
private boolean ToFromXmlDemo()
{
boolean returnValue = true;
SecurityZone zone1[] = new SecurityZone[1];
ZoneIdentityPermission zoneIdPerm1[] = new
ZoneIdentityPermission[1];
ZoneIdentityPermission zoneIdPerm2 = null;
ZoneGenerator zoneGen1 = new ZoneGenerator();
ZoneGenerator zoneGen2 = new ZoneGenerator();
zoneGen1.ResetIndex();
while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
if (zoneIdPerm1[0] == null) {
continue;
}
Console.WriteLine("*********************************"
+ "***********************\n");
zoneGen2.ResetIndex();
try {
zoneIdPerm2 = new ZoneIdentityPermission(PermissionState.None);
zoneIdPerm2.FromXml(zoneIdPerm1[0].ToXml());
Console.WriteLine(("Result of ToFromXml = "
+ zoneIdPerm2.ToString()));
}
catch (System.Exception e) {
Console.WriteLine(("ToFromXml failed :"
+ zoneIdPerm1[0].ToString() + e));
continue;
}
}
return returnValue;
} //ToFromXmlDemo
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
ZoneIdentityPermission-Klasse
ZoneIdentityPermission-Member
System.Security.Permissions-Namespace