Ejemplo n.º 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);
        }
Ejemplo n.º 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");
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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(")");
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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");
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 9
0
 public void EndDoesNothingNormally()
 {
     RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding());
     target.End();
     this.StreamAsString(target).Should().BeEmpty();
 }
Ejemplo n.º 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)");
 }
Ejemplo n.º 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)");
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }