Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIPermission.ToXml Method

Creates an XML encoding of the permission and its current state.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public override SecurityElement ToXml ()
public SecurityElement ToXml ()
public override function ToXml () : SecurityElement

Return Value

An XML encoding of the permission, including any state information.

For the complete example, see the UIPermission class topic.

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;

}

// 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

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft