/// <summary>Reconstructs a security object with a given state and policy level from an XML encoding.</summary>
/// <param name="e">The XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The policy level within which the code group exists. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
public void FromXml(SecurityElement e, PolicyLevel level)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
string text = e.Attribute("PermissionSetName");
PermissionSet permissionSet;
if (text != null && level != null)
{
permissionSet = level.GetNamedPermissionSet(text);
}
else
{
SecurityElement securityElement = e.SearchForChildByTag("PermissionSet");
if (securityElement != null)
{
Type type = Type.GetType(securityElement.Attribute("class"));
permissionSet = (PermissionSet)Activator.CreateInstance(type, true);
permissionSet.FromXml(securityElement);
}
else
{
permissionSet = new PermissionSet(new PermissionSet(PermissionState.None));
}
}
this.m_policy = new PolicyStatement(permissionSet);
this.m_children.Clear();
if (e.Children != null && e.Children.Count > 0)
{
foreach (object obj in e.Children)
{
SecurityElement securityElement2 = (SecurityElement)obj;
if (securityElement2.Tag == "CodeGroup")
{
this.AddChild(CodeGroup.CreateFromXml(securityElement2, level));
}
}
}
this.m_membershipCondition = null;
SecurityElement securityElement3 = e.SearchForChildByTag("IMembershipCondition");
if (securityElement3 != null)
{
string text2 = securityElement3.Attribute("class");
Type type2 = Type.GetType(text2);
if (type2 == null)
{
type2 = Type.GetType("System.Security.Policy." + text2);
}
this.m_membershipCondition = (IMembershipCondition)Activator.CreateInstance(type2, true);
this.m_membershipCondition.FromXml(securityElement3, level);
}
this.m_name = e.Attribute("Name");
this.m_description = e.Attribute("Description");
this.ParseXml(e, level);
}