public void FirstOrDefaultXsltElement_Element_ReturnsFirstElement() { var parent = new XsltElement("Parent"); var childName = "testName"; var child = new XsltElement("element", new XAttribute("name", childName)); parent.Add(child); var foundElement = parent.FirstOrDefaultXsltElement(child); Assert.Same(child, foundElement); }
public void FirstOrDefaultXsltElement_ElementName_ReturnsNull() { var parent = new XsltElement("Parent"); var childName = "testName"; var child = new XsltElement("element", new XAttribute("name", childName)); parent.Add(child); var foundElement = parent.FirstOrDefaultXsltElement("someOtherName"); Assert.Null(foundElement); }
public static void AddOrUpdateOutputElements(this XsltElement root, XsltElement outputElement) { var existingElement = root.FirstOrDefaultXsltElement(outputElement); if (existingElement != null) { existingElement.Add(outputElement.XsltElements()); return; } root.AddXsltElement(outputElement); }
public static XsltElement GetPathPartElement(XsltElement parentElement, XsltElement pathPartElement) => parentElement.FirstOrDefaultXsltElement(pathPartElement) ?? parentElement.AddAndReturnChild(pathPartElement);
public static XsltElement FirstOrDefaultXsltElement(this XsltElement root, XsltElement element) { var elementName = element.Attribute("name")?.Value; return(root.FirstOrDefaultXsltElement(elementName)); }