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

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



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.
    virtual void FromXml(SecurityElement^ element) override
        specifiedAsUnrestricted = false;
        stateFlags = (SoundPermissionState)0;

        // If XML indicates an unrestricted permission, 
        // make this permission unrestricted.
        String^ attributeString = 
            (String^) element->Attributes["Unrestricted"];
        if (attributeString != nullptr)
            specifiedAsUnrestricted = Convert::ToBoolean(attributeString);
            if (specifiedAsUnrestricted)
                stateFlags = SoundPermissionState::PlayAnySound;

        // If XML indicates a restricted permission, parse the flags.
        if (!specifiedAsUnrestricted)
            attributeString = (String^) element->Attributes["Flags"];
            if (attributeString != nullptr)
                stateFlags = (SoundPermissionState) Convert::ToInt32(
                    attributeString, 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

Community Additions

© 2015 Microsoft