Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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
)

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 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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.