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.
ISecurityEncodable::FromXml Method (SecurityElement^)
.NET Framework (current version)
Reconstructs a security object with a specified state from an XML encoding.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- e
-
Type:
System.Security::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.
public:
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(
Enum::Parse(SoundPermissionState::typeid,
attributeString, true));
}
}
}
.NET Framework
Available since 1.1
Available since 1.1
Show: