private static LineAndComments GetLineAndComments(DiffFileInfo file) { var res = new LineAndComments(); res.LineNum = file.CurLineNum; res.LineText = file.CurLine; List<AbstractedComment> comments = null; while (file.NextCommentIndex < file.Comments.Length && file.Comments[file.NextCommentIndex].Line == res.LineNum) { if (comments == null) comments = new List<AbstractedComment>(); comments.Add(file.Comments[file.NextCommentIndex++]); } if (!comments.IsNullOrEmpty()) res.Comments = comments; return res; }
/// <summary> /// Writes out one line and comments, if any. /// </summary> /// <param name="cell"> The table cell to use. </param> /// <param name="line"> Current line. </param> /// <param name="comments"> Comments. </param> /// <param name="commentIndex"> [In/Out] Current index into comments array. </param> private IEnumerable<Control> EncodeLineTextAndComments( ILineEncoder encoder, string prefix, LineAndComments line) { StringBuilder lineHtml = new StringBuilder(encoder.EncodeLine(line.LineText, int.MaxValue, TabValue)); StringBuilder commentsHtml = new StringBuilder(); if (line.Comments != null) { foreach (var comment in line.Comments) AddCommentToCell(commentsHtml, comment, prefix); } return new Control[2] { new Literal() { Text = "<pre class=\"Code\">" + lineHtml.ToString() + "</pre>" }, new Literal() { Text = commentsHtml.ToString() } }; }