예제 #1
0
        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);
        }
예제 #2
0
 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");
 }
예제 #3
0
        /// <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;
        }
예제 #4
0
 public void EndWithJsonPadding()
 {
     this.settings.JsonPCallback = "foo";
     RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding());
     target.End();
     this.StreamAsString(target).Should().Be(")");
 }
예제 #5
0
 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);
 }
예제 #6
0
        internal void InitializeRawValueWriter()
        {
            Debug.Assert(this.rawValueWriter == null, "The rawValueWriter has already been initialized.");

            this.rawValueWriter = new RawValueWriter(this.MessageWriterSettings, this.outputStream, this.encoding);
        }
예제 #7
0
 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");
 }
예제 #8
0
 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();
 }
예제 #9
0
 public void EndDoesNothingNormally()
 {
     RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding());
     target.End();
     this.StreamAsString(target).Should().BeEmpty();
 }
예제 #10
0
 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)");
 }
예제 #11
0
 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)");
 }
예제 #12
0
        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);
        }
예제 #13
0
        /// <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;
        }
예제 #14
0
        internal void InitializeRawValueWriter()
        {
            Debug.Assert(this.rawValueWriter == null, "The rawValueWriter has already been initialized.");

            this.rawValueWriter = new RawValueWriter(this.MessageWriterSettings, this.outputStream, this.encoding);
        }