/// <summary> /// Writes the code element body text. /// </summary> /// <param name="element">The element.</param> private void WriteBody(TextCodeElement element) { MemberElement memberElement = element as MemberElement; TypeElement parentTypeElement = GetTypeParent(element); bool isAbstract = memberElement != null && (memberElement.MemberModifiers & MemberModifiers.Abstract) == MemberModifiers.Abstract; bool inInterface = memberElement != null && parentTypeElement != null && parentTypeElement.Type == TypeElementType.Interface; if (!(isAbstract || inInterface)) { WriteBeginBlock(); Writer.WriteLine(); if (element.BodyText != null && element.BodyText.Trim().Length > 0) { WriteTextBlock(element.BodyText); Writer.WriteLine(); WriteEndBlock(element); WriteClosingComment(element, VBSymbol.BeginComment.ToString()); } else { WriteEndBlock(element); } } }
/// <summary> /// Creates a clone of the instance and assigns any state. /// </summary> /// <returns>Clone of this instance.</returns> public override object Clone() { TextCodeElement clone = base.Clone() as TextCodeElement; // // Copy state // clone._bodyText = _bodyText; return(clone); }
/// <summary> /// Writes a closing comment. /// </summary> /// <param name="element">The element.</param> /// <param name="commentPrefix">Comment prefix.</param> protected void WriteClosingComment(TextCodeElement element, string commentPrefix) { if (Configuration.Formatting.ClosingComments.Enabled) { string format = Configuration.Formatting.ClosingComments.Format; if (!string.IsNullOrEmpty(format)) { string formatted = element.ToString(format); Writer.Write( string.Format(CultureInfo.InvariantCulture, " {0}{1}", commentPrefix, formatted)); } } }
/// <summary> /// Writes a member body. /// </summary> /// <param name="element">The element.</param> private void WriteBody(TextCodeElement element) { WriteBeginBlock(); Writer.WriteLine(); if (element.BodyText != null && element.BodyText.Trim().Length > 0) { WriteTextBlock(element.BodyText); Writer.WriteLine(); WriteEndBlock(); WriteClosingComment(element, ClosingCommentPrefix); } else { TabCount--; WriteIndented(CSharpSymbol.EndBlock.ToString()); } }