private void Init(Stream streamArg, Encoding encodingArg, int bufferSize, bool shouldLeaveOpen) { this.stream = streamArg; this.encoding = encodingArg; this.encoder = encoding.GetEncoder(); if (bufferSize < MinBufferSize) { bufferSize = MinBufferSize; } charBuffer = new char[bufferSize]; byteBuffer = new byte[encoding.GetMaxByteCount(bufferSize)]; charLen = bufferSize; // If we're appending to a Stream that already has data, don't write // the preamble. if (stream.CanSeek && stream.Position > 0) { haveWrittenPreamble = true; } closable = !shouldLeaveOpen; #if MDA_SUPPORTED if (Mda.StreamWriterBufferedDataLost.Enabled) { String callstack = null; if (Mda.StreamWriterBufferedDataLost.CaptureAllocatedCallStack) { callstack = Environment.GetStackTrace(null, false); } mdaHelper = new MdaHelper(this, callstack); } #endif }
private void Init(Stream stream, System.Text.Encoding encoding, int bufferSize) { this.stream = stream; this.encoding = encoding; this.encoder = encoding.GetEncoder(); if (bufferSize < 0x80) { bufferSize = 0x80; } this.charBuffer = new char[bufferSize]; this.byteBuffer = new byte[encoding.GetMaxByteCount(bufferSize)]; this.charLen = bufferSize; if (stream.CanSeek && (stream.Position > 0L)) { this.haveWrittenPreamble = true; } this.closable = true; if (Mda.StreamWriterBufferedDataLost.Enabled) { string cs = null; if (Mda.StreamWriterBufferedDataLost.CaptureAllocatedCallStack) { cs = Environment.GetStackTrace(null, false); } this.mdaHelper = new MdaHelper(this, cs); } }
private void Init(Stream streamArg, Encoding encodingArg, int bufferSize, bool shouldLeaveOpen) { this.stream = streamArg; this.encoding = encodingArg; this.encoder = encoding.GetEncoder(); if (bufferSize < MinBufferSize) bufferSize = MinBufferSize; charBuffer = new char[bufferSize]; byteBuffer = new byte[encoding.GetMaxByteCount(bufferSize)]; charLen = bufferSize; // If we're appending to a Stream that already has data, don't write // the preamble. if (stream.CanSeek && stream.Position > 0) haveWrittenPreamble = true; closable = !shouldLeaveOpen; #if MDA_SUPPORTED if (Mda.StreamWriterBufferedDataLost.Enabled) { String callstack = null; if (Mda.StreamWriterBufferedDataLost.CaptureAllocatedCallStack) callstack = Environment.GetStackTrace(null, false); mdaHelper = new MdaHelper(this, callstack); } #endif }