Example #1
0
 /// <summary>
 /// Serializes an <see cref="XmlCodeElement"/> to XML.
 /// </summary>
 /// <param name="comment">The XML code comment to serialize.</param>
 /// <param name="writer">The XmlWriter to serialize to.</param>
 protected void Serialize(XmlCodeElement comment, System.Xml.XmlWriter writer)
 {
     if (comment != XmlCodeComment.Empty)
     {
         if (XmlElementRenderer.IsHandled(comment))
         {
             XmlRenderer renderer = XmlElementRenderer.Create(this, this.AssociatedEntry, comment);
             renderer.Render(writer);
         }
         else
         {
             if (comment is XmlContainerCodeElement)
             {
                 writer.WriteStartElement(comment.Element.ToString().ToLower());
                 foreach (XmlCodeElement element in ((XmlContainerCodeElement)comment).Elements)
                 {
                     this.Serialize(element, writer);
                 }
                 writer.WriteEndElement();
             }
             else
             {
                 writer.WriteStartElement(comment.Element.ToString().ToLower());
                 writer.WriteString(comment.Text);
                 writer.WriteEndElement();
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Factory method for instantiating correct XmlElementRenderers for the specified
        /// <paramref name="element"/>.
        /// </summary>
        /// <param name="associatedEntry">The entry this comment element was taken from.</param>
        /// <param name="element">The XML code comment element to handle.</param>
        /// <returns>A valid XmlRenderer for the <paramref name="element"/>.</returns>
        public static XmlRenderer Create(XmlRenderer from, Entry associatedEntry, XmlCodeElement element)
        {
            XmlElementRenderer renderer = null;

            switch (element.Element)
            {
            case XmlCodeElements.See:
                renderer = new SeeXmlElementRenderer(associatedEntry, (SeeXmlCodeElement)element);
                break;

            case XmlCodeElements.List:
                renderer = new ListXmlElementRenderer(associatedEntry, (ListXmlCodeElement)element);
                break;
            }
            renderer.Document = from.Document; // need to pass the reference over

            return(renderer);
        }