Example #1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(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;
            }
        }
Example #2
0
        internal void InitializeRawValueWriter()
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(this.rawValueWriter == null, "The rawValueWriter has already been initialized.");

            this.rawValueWriter = new RawValueWriter(this.MessageWriterSettings, this.outputStream, this.encoding);
        }
Example #3
0
        /// <summary>
        /// Closes the text writer.
        /// </summary>
        internal void CloseWriter()
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(this.rawValueWriter != null, "The text writer has not been initialized yet.");

            this.rawValueWriter.Dispose();
            this.rawValueWriter = null;
        }