/// <summary> /// Creates a clone of the instance and assigns any state. /// </summary> /// <returns>Clone of this instance.</returns> public override object Clone() { CommentedElement clone = base.Clone() as CommentedElement; foreach (ICommentElement comment in HeaderComments) { ICommentElement commentClone = comment.Clone() as ICommentElement; clone.AddHeaderComment(commentClone); } return(clone); }
/// <summary> /// Gets the formatted text to write for a comment. /// </summary> /// <param name="comment">Comment with text.</param> /// <returns>Formatted comment text.</returns> protected string FormatCommentText(ICommentElement comment) { string commentText = null; if (comment != null) { switch (comment.Type) { case CommentType.Line: int tabCount = 0; string commentLine = ProcessLineWhitepace(comment.Text, ref tabCount); string leadingSpace = CreateTabWhitespace(tabCount); commentText = leadingSpace + commentLine; break; default: commentText = comment.Text; break; } } return(commentText); }
/// <summary> /// Gets the formatted text to write for a comment. /// </summary> /// <param name="comment">Comment with text.</param> /// <returns>Formatted comment text.</returns> protected string FormatCommentText(ICommentElement comment) { string commentText = null; if (comment != null) { switch (comment.Type) { case CommentType.Line: int tabCount = 0; string commentLine = ProcessLineWhitepace(comment.Text, ref tabCount); string leadingSpace = CreateTabWhitespace(tabCount); commentText = leadingSpace + commentLine; break; default: commentText = comment.Text; break; } } return commentText; }
/// <summary> /// Adds a header comment to this element. /// </summary> /// <param name="comment">The comment.</param> public void AddHeaderComment(ICommentElement comment) { BaseHeaderComments.Add(comment); }