예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public static XsltElement GetPathPartElement(XsltElement parentElement, XsltElement pathPartElement) =>
 parentElement.FirstOrDefaultXsltElement(pathPartElement) ??
 parentElement.AddAndReturnChild(pathPartElement);
예제 #5
0
        public static XsltElement FirstOrDefaultXsltElement(this XsltElement root, XsltElement element)
        {
            var elementName = element.Attribute("name")?.Value;

            return(root.FirstOrDefaultXsltElement(elementName));
        }