protected override void Dispose(bool disposing) { try { if (this.messageOutputStream != null) { if (this.rawValueWriter != null) { this.rawValueWriter.Flush(); } // In the async case the underlying stream is the async buffered stream, so we have to flush that explicitely. if (this.asynchronousOutputStream != null) { this.asynchronousOutputStream.FlushSync(); this.asynchronousOutputStream.Dispose(); } // Dipose the message stream (note that we OWN this stream, so we always dispose it). this.messageOutputStream.Dispose(); } } finally { this.messageOutputStream = null; this.asynchronousOutputStream = null; this.outputStream = null; this.rawValueWriter = null; } base.Dispose(disposing); }
public void WriteRawValueWritesDate() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); Date value = new Date(2014, 9, 18); target.WriteRawValue(value); this.StreamAsString(target).Should().Be("2014-09-18"); }
/// <summary> /// Closes the text writer. /// </summary> internal void CloseWriter() { Debug.Assert(this.rawValueWriter != null, "The text writer has not been initialized yet."); this.rawValueWriter.Dispose(); this.rawValueWriter = null; }
public void EndWithJsonPadding() { this.settings.JsonPCallback = "foo"; RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); target.End(); this.StreamAsString(target).Should().Be(")"); }
public void WriteRawValueWritesRawString() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); const string value = "string value"; target.WriteRawValue(value); this.StreamAsString(target).Should().Be(value); }
internal void InitializeRawValueWriter() { Debug.Assert(this.rawValueWriter == null, "The rawValueWriter has already been initialized."); this.rawValueWriter = new RawValueWriter(this.MessageWriterSettings, this.outputStream, this.encoding); }
public void WriteRawValueWritesTimeOfDay() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); TimeOfDay value = new TimeOfDay(9, 47, 5, 900); target.WriteRawValue(value); this.StreamAsString(target).Should().Be("09:47:05.9000000"); }
private string StreamAsString(RawValueWriter target) { if (target.TextWriter != null) { target.TextWriter.Flush(); } this.stream.Flush(); this.stream.Position = 0; return new StreamReader(this.stream).ReadToEnd(); }
public void EndDoesNothingNormally() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); target.End(); this.StreamAsString(target).Should().BeEmpty(); }
public void WriteRawValueWritesGeometryValue() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); var value2 = GeometryPoint.Create(1.2, 3.16); target.WriteRawValue(value2); this.StreamAsString(target).Should().Be("SRID=0;POINT (1.2 3.16)"); }
public void WriteRawValueWritesGeographyValue() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); var value = GeographyPoint.Create(22.2, 22.2); target.WriteRawValue(value); this.StreamAsString(target).Should().Be("SRID=4326;POINT (22.2 22.2)"); }