상속: IList
예제 #1
0
파일: WikiDiff.cs 프로젝트: svick/AWB
        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>");
        }
예제 #2
0
        private static void WriteCharBlock(TextWriter writer, char prefix, Range items)
        {
            bool newline = true;
            int counter = 0;
            foreach (char c in items)
            {
                if (c == '\n' && !newline)
                {
                    writer.WriteLine();
                    newline = true;
                }

                if (newline)
                {
                    writer.Write(prefix);
                    newline = false;
                    counter = 0;
                }

                if (c == '\n')
                {
                    writer.WriteLine("[newline]");
                    newline = true;
                }
                else
                {
                    writer.Write(c);
                    counter++;
                    if (counter == 60)
                    {
                        writer.WriteLine();
                        newline = true;
                    }
                }
            }
            if (!newline)
            {
                writer.WriteLine();
            }
        }
예제 #3
0
 private static void WriteStringBlock(TextWriter writer, char prefix, Range items)
 {
     foreach (object item in items)
     {
         writer.Write(prefix);
         writer.WriteLine(item.ToString());
     }
 }
예제 #4
0
 private static void WriteBlock(TextWriter writer, char prefix, Range items)
 {
     if (items.Count > 0 && items[0] is char)
         WriteCharBlock(writer, prefix, items);
     else
         WriteStringBlock(writer, prefix, items);
 }