/// <summary> /// Writes a collection of element attributes. /// </summary> /// <param name="element">Attributed code element.</param> private void WriteAttributes(AttributedElement element) { foreach (IAttributeElement attribute in element.Attributes) { attribute.Accept(this); } }
/// <summary> /// Applies attributes and comments to a code element. /// </summary> /// <param name="codeElement">Code element to apply to.</param> /// <param name="comments">Comments to apply.</param> /// <param name="attributes">Attributes to apply.</param> protected static void ApplyCommentsAndAttributes( CodeElement codeElement, ReadOnlyCollection <ICommentElement> comments, ReadOnlyCollection <AttributeElement> attributes) { CommentedElement commentedElement = codeElement as CommentedElement; if (commentedElement != null) { // // Add any header comments // foreach (ICommentElement comment in comments) { commentedElement.AddHeaderComment(comment); } } AttributedElement attributedElement = codeElement as AttributedElement; if (attributedElement != null) { foreach (AttributeElement attribute in attributes) { attributedElement.AddAttribute(attribute); // // Treat attribute comments as header comments // if (attribute.HeaderComments.Count > 0) { foreach (ICommentElement comment in attribute.HeaderComments) { attributedElement.AddHeaderComment(comment); } attribute.ClearHeaderCommentLines(); } } } }