/// <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(); } } } }
/// <summary> /// Exports the current entry. /// </summary> /// <param name="current">The current entry to export.</param> /// <returns>The name of the rendered XML file</returns> protected override string Export(Entry current) { string filename = string.Format("{0}{1}{2}.xml", this.TempDirectory, current.Key, string.IsNullOrEmpty(current.SubKey) ? string.Empty : "-" + this.IllegalFileCharacters.Replace(current.SubKey, string.Empty) ); try { Rendering.XmlRenderer r = Rendering.XmlRenderer.Create(current, this.Document); if (r != null) { using (System.Xml.XmlWriter writer = XmlWriter.Create(filename, this.outputSettings)) { r.Render(writer); } } } catch (Exception ex) { if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } // we will deal with it later this.ExportExceptions.Add(ex); } return(filename); }
/// <summary> /// Exports the <paramref name="current"/> entry to intermediate XML format. /// </summary> /// <include file='../code-documentation/exporter.xml' path='docs/exporter[@name="export"]'/> protected virtual string Export(Entry current) { string filename = string.Format("{0}{1}{2}.xml", this.TempDirectory, current.Key, string.IsNullOrEmpty(current.SubKey) ? string.Empty : "-" + this.IllegalFileCharacters.Replace(current.SubKey, string.Empty) ); try { Rendering.XmlRenderer r = Rendering.XmlRenderer.Create(current, Document); if (null == r) { ExportExceptions.Add(new Exception($"No XML renderer for the Entry {current.Name}")); } using (System.Xml.XmlWriter writer = XmlWriter.Create(filename)) { r.Render(writer); } } catch (Exception ex) { if (_fileSystem.FileExists(filename)) { _fileSystem.DeleteFile(filename); } // ignore it and add it to the list of exceptions, try and add more details if (current != null) { ExportException issue = new ExportException( $"Failed to export member '{current.Name}'.", ex); ex = issue; } ExportExceptions.Add(ex); } return(filename); }