internal void InitializeTextWriter()
        {
            Stream outputStream;

            if (MessageStreamWrapper.IsNonDisposingStream(this.outputStream) || (this.outputStream is AsyncBufferedStream))
            {
                outputStream = this.outputStream;
            }
            else
            {
                outputStream = MessageStreamWrapper.CreateNonDisposingStream(this.outputStream);
            }
            this.textWriter = new StreamWriter(outputStream, this.encoding);
        }
Exemple #2
0
        private void InitializeTextWriter()
        {
            // We must create the text writer over a stream which will ignore Dispose, since we need to be able to Dispose
            // the writer without disposing the underlying message stream.
            Stream nonDisposingStream;

            if (MessageStreamWrapper.IsNonDisposingStream(this.stream) || this.stream is AsyncBufferedStream)
            {
                // AsynBufferedStream ignores Dispose
                nonDisposingStream = this.stream;
            }
            else
            {
                nonDisposingStream = MessageStreamWrapper.CreateNonDisposingStream(this.stream);
            }

            this.textWriter = new StreamWriter(nonDisposingStream, this.encoding);
        }
        internal void InitializeTextWriter()
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(this.textWriter == null, "The text writer has already been initialized.");

            // We must create the text writer over a stream which will ignore Dispose, since we need to be able to Dispose
            // the writer without disposing the underlying message stream.
            Stream nonDisposingStream;

            if (MessageStreamWrapper.IsNonDisposingStream(this.outputStream) || this.outputStream is AsyncBufferedStream)
            {
                // AsynBufferedStream ignores Dispose
                nonDisposingStream = this.outputStream;
            }
            else
            {
                nonDisposingStream = MessageStreamWrapper.CreateNonDisposingStream(this.outputStream);
            }

            this.textWriter = new StreamWriter(nonDisposingStream, this.encoding);
        }