private string WriteNode( IDataStoreNode node, bool indent ) { var sb = new StringBuilder(); using( var writer = new XmlDataStoreWriter(sb, indent) ) { if( node.NotNullReference() ) writer.Write(node); } return sb.ToString(); }
/// <summary> /// Called when the object is being disposed of. Inheritors must call base.OnDispose to be properly disposed. /// </summary> /// <param name="disposing">If set to <c>true</c>, release both managed and unmanaged resources; otherwise release only the unmanaged resources.</param> protected override void OnDispose( bool disposing ) { if( disposing ) { //// dispose-only (i.e. non-finalizable) logic //// (managed, disposable resources you own) if( this.writer.NotNullReference() ) { this.writer.WriteObjectEnd(); this.writer.Dispose(); this.writer = null; } } //// shared cleanup logic //// (unmanaged resources) base.OnDispose(disposing); }
/// <summary> /// Returns a new <see cref="LogEntrySerializer"/> instance. /// If possible, use the other method to create an instance. /// </summary> /// <param name="xmlStream">The <see cref="ITextWriter"/> to write the Xml contents to.</param> /// <returns>The new <see cref="LogEntrySerializer"/> instance created.</returns> public static LogEntrySerializer ToXmlStream( ITextWriter xmlStream ) { var writer = new XmlDataStoreWriter(xmlStream); writer.WriteObjectStart("LogEntries"); return new LogEntrySerializer(writer); }
private LogEntrySerializer( XmlDataStoreWriter writer ) { Ensure.That(writer).NotNull().NotDisposed(); this.writer = writer; }