WikiFunctions.WikiDiff.WordDiff C# (CSharp) Method

WordDiff() private static method

private static WordDiff ( StringBuilder res, Range range, Range otherRange, IList words, IList otherWords ) : void
res StringBuilder
range Range
otherRange Range
words IList
otherWords IList
return void
        private static void WordDiff(StringBuilder res, Range range, Range otherRange, IList<Word> words,
                                     IList<Word> otherWords)
        {
            bool open = false;

            for (int i = 0; i < range.Count; i++)
            {
                if (i >= otherRange.Count ||
                    words[range.Start + i].ToString() != otherWords[otherRange.Start + i].ToString())
                {
                    if (!open) res.Append("<span class='diffchange'>");
                    open = true;
                }
                else
                {
                    if (open) res.Append("</span>");
                    open = false;
                }
                res.Append(HttpUtility.HtmlEncode(words[range.Start + i].ToString()));
            }

            if (open)
            {
                res.Append("</span>");
            }
        }