UIPermission.ToXml-Methode
Erstellt eine XML-Codierung der Berechtigung und ihres aktuellen Zustands.
Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Overrides Function ToXml As SecurityElement
'Usage
Dim instance As UIPermission
Dim returnValue As SecurityElement
returnValue = instance.ToXml
public override SecurityElement ToXml ()
public:
virtual SecurityElement^ ToXml () override
public SecurityElement ToXml ()
public override function ToXml () : SecurityElement
Rückgabewert
Eine XML-Codierung der Berechtigung, einschließlich sämtlicher Zustandsinformationen.
Beispiel
Das vollständige Beispiel finden Sie unter der UIPermission-Klasse.
Private Function ToFromXmlDemo() As Boolean
Dim returnValue As Boolean = True
Dim ui1 As UIPermissionWindow
Dim cb1 As UIPermissionClipboard
Dim uiIdPerm1, uiIdPerm2 As UIPermission
Dim uiGen1 As New UIGenerator()
Dim uiGen2 As New UIGenerator()
uiGen1.ResetIndex()
While uiGen1.CreateUI(ui1, cb1)
uiIdPerm1 = New UIPermission(ui1, cb1)
Console.WriteLine("********************************************************" & ControlChars.Lf)
uiGen2.ResetIndex()
Try
uiIdPerm2 = New UIPermission(PermissionState.None)
uiIdPerm2.FromXml(uiIdPerm1.ToXml())
Console.WriteLine(("Result of ToFromXml = " & uiIdPerm2.ToString()))
Catch e As Exception
Console.WriteLine(("ToFromXml failed :" & uiIdPerm1.ToString() & e.ToString()))
GoTo ContinueWhile1
End Try
ContinueWhile1:
End While
Return returnValue
End Function 'ToFromXmlDemo
private bool ToFromXmlDemo()
{
bool returnValue = true;
UIPermissionWindow ui1;
UIPermissionClipboard cb1;
UIPermission uiIdPerm1, uiIdPerm2;
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI( out ui1, out cb1))
{
uiIdPerm1 = new UIPermission(ui1, cb1);
Console.WriteLine("********************************************************\n");
uiGen2.ResetIndex();
try
{
uiIdPerm2 = new UIPermission(PermissionState.None);
uiIdPerm2.FromXml(uiIdPerm1.ToXml());
Console.WriteLine("Result of ToFromXml = " +
uiIdPerm2.ToString());
}
catch (Exception e)
{
Console.WriteLine("ToFromXml failed :" + uiIdPerm1.ToString() + e);
continue;
}
}
return returnValue;
}
bool ToFromXmlDemo()
{
bool returnValue = true;
UIPermissionWindow ui1;
UIPermissionClipboard cb1;
UIPermission^ uiIdPerm1;
UIPermission^ uiIdPerm2;
UIGenerator^ uiGen1 = gcnew UIGenerator;
UIGenerator^ uiGen2 = gcnew UIGenerator;
uiGen1->ResetIndex();
while ( uiGen1->CreateUI( &ui1, &cb1 ) )
{
uiIdPerm1 = gcnew UIPermission( ui1, cb1 );
Console::WriteLine( "********************************************************\n" );
uiGen2->ResetIndex();
try
{
uiIdPerm2 = gcnew UIPermission( PermissionState::None );
uiIdPerm2->FromXml( uiIdPerm1->ToXml() );
Console::WriteLine( "Result of ToFromXml = {0}", uiIdPerm2 );
}
catch ( Exception^ e )
{
Console::WriteLine( "ToFromXml failed :{0}{1}", uiIdPerm1, 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;
UIPermissionWindow ui1[] = new UIPermissionWindow[1];
UIPermissionClipboard cb1[] = new UIPermissionClipboard[1];
UIPermission uiIdPerm1[] = new UIPermission[1];
UIPermission uiIdPerm2 = null;
UIGenerator uiGen1 = new UIGenerator();
UIGenerator uiGen2 = new UIGenerator();
uiGen1.ResetIndex();
while (uiGen1.CreateUI(uiIdPerm1, ui1, cb1)) {
if (uiIdPerm1 == null) {
continue;
}
Console.WriteLine("*************************************"
+ "*******************\n");
uiGen2.ResetIndex();
try {
uiIdPerm2 = new UIPermission(PermissionState.None);
uiIdPerm2.FromXml(uiIdPerm1[0].ToXml());
Console.WriteLine(("Result of ToFromXml = "
+ uiIdPerm2.ToString()));
}
catch (System.Exception e) {
Console.WriteLine(("ToFromXml failed :"
+ uiIdPerm1[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
UIPermission-Klasse
UIPermission-Member
System.Security.Permissions-Namespace