Exemplo n.º 1
0
        /// <summary>
        /// Calculates the difference between two incoming lists on a per-line basis.
        /// The lists are first combined as single lines, then a line-by-line change is calculated and reassembled.
        /// </summary>
        /// <param name="firstResourceData">First list of literals to compare</param>
        /// <param name="secondResouceData">Second list of literals to compare</param>
        /// <returns>Returns the result of the comparison, where all line changes can be tracked with tags.</returns>
        private Tuple <IList <string>, IList <string> > CalculateLiteralListDifference(IList <string> firstResourceData, IList <string> secondResouceData)
        {
            IDiffer      differ = new Differ();
            const string lineEndingSeperator = "\n";

            // combine two
            string resourceAFlattenedCompareList = string.Join(lineEndingSeperator, firstResourceData);
            string resourceBFlattenedCompareList = string.Join(lineEndingSeperator, secondResouceData);

            var resourcePropertyValueDifference = differ.CreateDiffs(resourceAFlattenedCompareList, resourceBFlattenedCompareList, false, false, new LineChunker());
            var result = GenerateDifferenceOutputFormat(resourcePropertyValueDifference, lineEndingSeperator);

            return(new Tuple <IList <string>, IList <string> >(result.Item1.Split(lineEndingSeperator), result.Item2.Split(lineEndingSeperator)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the differences of two literals on a character basis. This means that changes of single characters can be fully traced.
        /// </summary>
        /// <param name="firstLiteral">First literal to compare</param>
        /// <param name="secondLiteral">Second literal to compare</param>
        /// <returns>Returns the result of the comparison, where all changes can be tracked with tags.</returns>
        private Tuple <IList <string>, IList <string> > CalculateLiteralSingleValueDiff(string firstLiteral, string secondLiteral)
        {
            IDiffer differ = new Differ();

            var resourcePropertyValueDifference = differ.CreateDiffs(firstLiteral, secondLiteral, false, false, new CharacterChunker());
            var result = GenerateDifferenceOutputFormat(resourcePropertyValueDifference);

            return(new Tuple <IList <string>, IList <string> >(new List <string>()
            {
                result.Item1
            }, new List <string>()
            {
                result.Item2
            }));
        }