public static void SerializeUtf8 (XmlSerializer serializer, Stream stream, object o) { if (serializer == null) throw new ArgumentNullException ("serializer"); if (stream == null) throw new ArgumentNullException ("stream"); if (o == null) throw new ArgumentNullException ("o"); UnclosableStream unclosable_stream = new UnclosableStream (stream); BufferedStream buffered_stream = new BufferedStream (unclosable_stream, 8192); Stopwatch w = new Stopwatch (); w.Start (); XmlTextWriter xml_writer = new XmlTextWriter (buffered_stream, Encoding.UTF8); xml_writer.Formatting = Formatting.Indented; serializer.Serialize (xml_writer, o); // This will flush the stream and release the buffer. // Normally it also closes the underlying stream, // which is why it wraps an UnclosableStream. buffered_stream.Dispose (); w.Stop (); if (Debug) Log.Debug (">>> Serialization of {0}: {1}", o.GetType (), w); }
override public void AddToStream (Stream stream, EventTracker tracker) { if (tracker != null) tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri)); // We can't just use a StreamWriter here, since that // will close the underlying stream when it gets // disposed. UnclosableStream unclosable = new UnclosableStream (stream); StreamWriter writer = new StreamWriter (unclosable); foreach (string str in body) writer.WriteLine (str); writer.Close (); }
override public void AddToStream (Stream stream, EventTracker tracker) { if (tracker != null) tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri)); UnclosableStream unclosable; unclosable = new UnclosableStream (stream); ZipOutputStream zip_out; zip_out = new ZipOutputStream (unclosable); foreach (FileSystemObject fso in Children) WriteObjectToZip (zip_out, fso, tracker); zip_out.Finish (); zip_out.Close (); }
public static void SerializeUtf8(XmlSerializer serializer, Stream stream, object o) { if (serializer == null) { throw new ArgumentNullException("serializer"); } if (stream == null) { throw new ArgumentNullException("stream"); } if (o == null) { throw new ArgumentNullException("o"); } UnclosableStream unclosable_stream = new UnclosableStream(stream); BufferedStream buffered_stream = new BufferedStream(unclosable_stream, 8192); Stopwatch w = new Stopwatch(); w.Start(); XmlTextWriter xml_writer = new XmlTextWriter(buffered_stream, Encoding.UTF8); xml_writer.Formatting = Formatting.Indented; serializer.Serialize(xml_writer, o); // This will flush the stream and release the buffer. // Normally it also closes the underlying stream, // which is why it wraps an UnclosableStream. buffered_stream.Dispose(); w.Stop(); if (Debug) { Log.Debug(">>> Serialization of {0}: {1}", o.GetType(), w); } }
override public void AddToStream (Stream stream, EventTracker tracker) { if (ChildCount > 1) throw new Exception ("Bzip2 file " + Uri + " has " + ChildCount + " children"); if (tracker != null) tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri)); UnclosableStream unclosable; unclosable = new UnclosableStream (stream); BZip2OutputStream bz2_out; bz2_out = new BZip2OutputStream (unclosable); MemoryStream memory; memory = new MemoryStream (); // There should just be one child foreach (FileObject file in Children) file.AddToStream (memory, tracker); bz2_out.Write (memory.ToArray (), 0, (int) memory.Length); memory.Close (); bz2_out.Close (); }
override public void AddToStream (Stream stream, EventTracker tracker) { if (tracker != null) tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri)); UnclosableStream unclosable; unclosable = new UnclosableStream (stream); TarOutputStream tar_out; tar_out = new TarOutputStream (unclosable); foreach (FileSystemObject fso in Children) WriteObjectToTar (tar_out, fso, tracker); // This calls close on the underlying stream, // which is why we wrapped the stream in an // UnclosableStream. tar_out.Close (); }