Ejemplo n.º 1
0
        private static IEnumerable <Difference> Compare(
            XElement firstElement,
            XElement secondElement,
            IEnumerable <string> comparedAttributeKeys,
            FoundOnlyIn foundOnlyIn)
        {
            var diffs = new List <Difference>();

            var firstXPath       = GetXPathOf(firstElement, comparedAttributeKeys);
            var elementsInSecond = secondElement.Document.XPathSelectElements(firstXPath);

            if (elementsInSecond.Any() == false)
            {
                diffs.Add(Difference.Create(firstElement.ShallowCopy(), firstXPath, foundOnlyIn));
            }
            else if (elementsInSecond.Count() == 1)
            {
                // OK.
            }
            foreach (var child in firstElement.Elements())
            {
                diffs.AddRange(Compare(child, secondElement, comparedAttributeKeys, foundOnlyIn));
            }
            return(diffs);
        }
Ejemplo n.º 2
0
 internal static Difference Create(XElement element, string xpath, FoundOnlyIn foundOnlyIn)
 {
     if (foundOnlyIn == FoundOnlyIn.First)
     {
         return(new Difference(element, xpath, null, null));
     }
     else
     {
         return(new Difference(null, null, element, xpath));
     }
 }