Export (0) Print
Expand All

ISecurityEncodable.FromXml Method

Reconstructs a security object with a specified state from an XML encoding.

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

void FromXml (
	SecurityElement e
)
void FromXml (
	SecurityElement e
)
function FromXml (
	e : SecurityElement
)
Not applicable.

Parameters

e

The XML encoding to use to reconstruct the security object.

Custom code that extends security objects needs to implement the ToXml and FromXml methods to make the objects security-encodable.

The following code example demonstrates implementing the FromXml method. This code example is part of a larger example provided for the ISecurityEncodable class.

// Populate the permission's fields from XML.
public override void FromXml(SecurityElement e) 
{
    m_specifiedAsUnrestricted = false;
    m_flags = 0;

    // If XML indicates an unrestricted permission, make this permission unrestricted.
    String s = (String) e.Attributes["Unrestricted"];
    if (s != null) 
    {
        m_specifiedAsUnrestricted = Convert.ToBoolean(s);
        if (m_specifiedAsUnrestricted)
            m_flags = SoundPermissionState.PlayAnySound;
    }

    // If XML indicates a restricted permission, parse the flags.
    if (!m_specifiedAsUnrestricted) 
    {
        s = (String) e.Attributes["Flags"];
        if (s != null) 
        {
            m_flags = (SoundPermissionState)
            Convert.ToInt32(Enum.Parse(typeof(SoundPermission), s, true));
        }
    }
}

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft