public void Equal() { SecurityElement elem = CreateElement(); SecurityElement elem2 = CreateElement(); Assert.True(elem.Equal(elem2)); SecurityElement child = (SecurityElement)elem2.Children[0]; child = (SecurityElement)child.Children[1]; child.Text = "some text"; Assert.False(elem.Equal(elem2)); }
public void Equal() { int iTest = 0; SecurityElement elem2 = CreateElement(); iTest++; Assert.IsTrue(elem.Equal(elem2), "#1"); iTest++; SecurityElement child = (SecurityElement)elem2.Children [0]; iTest++; child = (SecurityElement)child.Children [1]; iTest++; child.Text = "some text"; iTest++; Assert.IsFalse(elem.Equal(elem2), "#2"); }
// Delete the specified security element if the current time is past // the time stored in the destroytime tag. private static SecurityElement DestroyTree(SecurityElement xmlElement) { SecurityElement localXmlElement = xmlElement; SecurityElement destroyElement = localXmlElement.SearchForChildByTag("destroytime"); // Verify that a destroytime tag exists. //<Snippet17> if (localXmlElement.SearchForChildByTag("destroytime") != null) //</Snippet17> { // Retrieve the destroytime text to get the time // the tree can be destroyed. //<Snippet18> string storedDestroyTime = localXmlElement.SearchForTextOfTag("destroytime"); //</Snippet18> DateTime destroyTime = DateTime.Parse(storedDestroyTime); if (DateTime.Now > destroyTime) { localXmlElement = null; Console.WriteLine("The XML security tree has been deleted."); } } // Verify that xmlElement is of type SecurityElement. //<Snippet21> if (xmlElement.GetType().Equals( typeof(System.Security.SecurityElement))) //</Snippet21> { // Determine whether the localXmlElement object // differs from xmlElement. //<Snippet20> if (xmlElement.Equals(localXmlElement)) //</Snippet20> { // Verify that the tags, attributes and children of the // two security elements are identical. //<Snippet22> if (xmlElement.Equal(localXmlElement)) //</Snippet22> { // Return the original security element. return(xmlElement); } } } // Return the modified security element. return(localXmlElement); }