public static void PolicyStatementCallMethods() { PolicyStatement ps = new PolicyStatement(new PermissionSet(new PermissionState())); PolicyStatement ps2 = ps.Copy(); bool equals = ps.Equals(ps2); int hash = ps.GetHashCode(); SecurityElement se = new SecurityElement(""); PolicyLevel pl = (PolicyLevel)Activator.CreateInstance(typeof(PolicyLevel), true); ps.FromXml(se); ps.FromXml(se, pl); se = ps.ToXml(); se = ps.ToXml(pl); }
public static void PolicyStatementCallMethods() { PolicyStatement ps = new PolicyStatement(new PermissionSet(new PermissionState())); PolicyStatement ps2 = ps.Copy(); bool equals = ps.Equals(ps2); int hash = ps.GetHashCode(); SecurityElement se = new SecurityElement(""); PolicyLevel pl = (PolicyLevel)FormatterServices.GetUninitializedObject(typeof(PolicyLevel)); ps.FromXml(se); ps.FromXml(se, pl); se = ps.ToXml(); se = ps.ToXml(pl); }
public void ToFromXml_PolicyLevelNull() { PolicyStatement ps = new PolicyStatement(null); SecurityElement se = ps.ToXml(null); ps.FromXml(se, null); }
public void ToFromXml_RoundTrip() { PolicyStatement ps1 = new PolicyStatement(Unrestricted, PolicyStatementAttribute.All); SecurityElement se = ps1.ToXml(); PolicyStatement ps2 = new PolicyStatement(null); ps2.FromXml(se, null); Assert.AreEqual(ps1.ToXml().ToString(), ps2.ToXml().ToString(), "Xml"); }
// If a class attribute is not found in the specified PolicyStatement, // add a child XML element with an added class attribute. private static void addXmlMember(ref PolicyStatement policyStatement) { SecurityElement xmlElement = policyStatement.ToXml(); if (xmlElement.Attribute("class") == null) { SecurityElement newElement = new SecurityElement("PolicyStatement"); newElement.AddAttribute("class", policyStatement.ToString()); newElement.AddAttribute("version", "1.1"); newElement.AddChild(new SecurityElement("PermissionSet")); policyStatement.FromXml(newElement); Console.Write("Added the class attribute and modified its "); Console.WriteLine("version number.\n" + newElement.ToString()); } }
public void FromXml_BadSecurityElement() { PolicyStatement ps = new PolicyStatement(null); ps.FromXml(new SecurityElement("Bad")); }
public void FromXml_SecurityElementNull() { PolicyStatement ps = new PolicyStatement(null); ps.FromXml(null, PolicyLevel.CreateAppDomainLevel()); }
public void FromXml_Null() { PolicyStatement ps = new PolicyStatement(null); ps.FromXml(null); }