/// <summary> /// Use an iterator and a visitor to print info of every comment from within a document. /// </summary> private static void PrintAllCommentInfo(List <Comment> comments) { // Create an object that inherits from the DocumentVisitor class CommentInfoPrinter commentVisitor = new CommentInfoPrinter(); // Get the enumerator from the document's comment collection and iterate over the comments using (IEnumerator <Comment> enumerator = comments.GetEnumerator()) { while (enumerator.MoveNext()) { Comment currentComment = enumerator.Current; // Accept our DocumentVisitor it to print information about our comments if (currentComment != null) { // Get CommentRangeStart from our current comment and construct its information CommentRangeStart commentRangeStart = (CommentRangeStart)currentComment.PreviousSibling.PreviousSibling.PreviousSibling; commentRangeStart.Accept(commentVisitor); // Construct current comment information currentComment.Accept(commentVisitor); // Get CommentRangeEnd from our current comment and construct its information CommentRangeEnd commentRangeEnd = (CommentRangeEnd)currentComment.PreviousSibling; commentRangeEnd.Accept(commentVisitor); } } // Output of all information received Console.WriteLine(commentVisitor.GetText()); } }
public static string Render(Comment comment) { var renderer = new XmlCommentRenderer(); var builder = new StringBuilder(); comment.Accept(renderer, builder); return(builder.ToString().TrimWhitespace()); }
public string Render(ApiContext context, Comment comment) { if (comment == null) { return(string.Empty); } var builder = new EncodedStringBuilder(); comment.Accept(this, new CommentRendererContext(context, builder)); return(builder.ToString()); }