FromXml Method
Collapse the table of content
Expand the table of content

ReflectionPermission.FromXml Method

Reconstructs a permission with a specified state from an XML encoding.

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

public override void FromXml (
	SecurityElement esd
)
public void FromXml (
	SecurityElement esd
)
public override function FromXml (
	esd : SecurityElement
)

Parameters

esd

The XML encoding to use to reconstruct the permission.

Exception typeCondition

ArgumentNullException

The esd parameter is a null reference (Nothing in Visual Basic).

ArgumentException

The esd parameter is not a valid permission element.

-or-

The esd parameter's version number is not valid.

private bool ToFromXmlDemo()
{

    bool returnValue = true;

    ReflectionPermissionFlag reflection1;
    ReflectionPermission reflectionPerm1, reflectionPerm2;
    ReflectionGenerator reflectionGen1 = new ReflectionGenerator();
    ReflectionGenerator reflectionGen2 = new ReflectionGenerator();
    reflectionGen1.ResetIndex();
    while (reflectionGen1.CreateReflection(out reflection1))
    {
        reflectionPerm1 = new ReflectionPermission(reflection1);
        Console.WriteLine("********************************************************\n");
        reflectionGen2.ResetIndex();
        try
        {
            reflectionPerm2 = new ReflectionPermission(PermissionState.None);
            reflectionPerm2.FromXml(reflectionPerm1.ToXml());
            Console.WriteLine("Result of ToFromXml = " +
                reflectionPerm2.ToString());

        }
        catch (Exception e)
        {
            Console.WriteLine("ToFromXml failed :" + reflectionPerm1.ToString() + e);
            continue;
        }
    }

    return returnValue;

}

private boolean ToFromXmlDemo() 
{
    boolean returnValue = true;
    ReflectionPermissionFlag reflection1[] = 
        new ReflectionPermissionFlag[1];
    ReflectionPermission reflectionPerm1[] = 
        new ReflectionPermission[1];
    ReflectionPermission reflectionPerm2[] = 
        new ReflectionPermission[1];
    ReflectionGenerator reflectionGen1 =  
        new ReflectionGenerator();
    ReflectionGenerator reflectionGen2 =  
        new ReflectionGenerator();
    reflectionGen1.ResetIndex();
    while(reflectionGen1.CreateReflection(reflectionPerm1, reflection1)) {
        if (reflectionPerm1[0] == null) {
            continue ;
        }
        Console.WriteLine("**************************************" 
            + "******************\n");
        reflectionGen2.ResetIndex();
        try {
            reflectionPerm2[0] = 
                new ReflectionPermission(PermissionState.None);
            reflectionPerm2[0].FromXml(reflectionPerm1[0].ToXml());
            Console.WriteLine(("Result of ToFromXml = " 
                + reflectionPerm2[0].ToString()));
        }
        catch(System.Exception e) {
            Console.WriteLine(("ToFromXml failed :" 
                + reflectionPerm1[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

Community Additions

ADD
Show:
© 2016 Microsoft