public BufferedReadStream(Stream baseStream, int initialSize, int maxBufferSize, bool minimalRead) { if (baseStream == null) { throw new ArgumentNullException("baseStream"); } if (!baseStream.CanRead) { throw new ArgumentException("baseStream"); } if (maxBufferSize < 1) { maxBufferSize = 1; } if (initialSize < 1) { initialSize = 1; } if (initialSize > maxBufferSize) { initialSize = maxBufferSize; } _baseStream = baseStream; _buffer = new StreamReadBuffer(baseStream, initialSize, maxBufferSize, minimalRead); _buffer.MaxSize = maxBufferSize; _buffer.MinimalRead = minimalRead; }
public BufferedReadStream(Stream baseStream, int initialSize, int maxBufferSize, bool minimalRead) { if (baseStream == null) throw new ArgumentNullException("baseStream"); if (!baseStream.CanRead) throw new ArgumentException("baseStream"); if (maxBufferSize < 1) maxBufferSize = 1; if (initialSize < 1) initialSize = 1; if (initialSize > maxBufferSize) initialSize = maxBufferSize; _baseStream = baseStream; _buffer = new StreamReadBuffer(baseStream, initialSize, maxBufferSize, minimalRead); _buffer.MaxSize = maxBufferSize; _buffer.MinimalRead = minimalRead; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (_buffer != null) { _buffer.Dispose(); _buffer = null; } if (!_leaveOpen) { _baseStream.Dispose(); } } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (_buffer != null) { _buffer.Dispose(); _buffer = null; } if (CloseBaseStream) { _baseStream.Flush(); _baseStream.Dispose(); } } }
private BufferedReadStream( Stream baseStream, bool leaveOpen, bool minimalRead) { if (baseStream == null) { throw new ArgumentNullException(nameof(baseStream)); } if (!baseStream.CanRead) { throw new ArgumentException(nameof(baseStream), "Stream is not readable."); } _baseStream = baseStream; _leaveOpen = leaveOpen; _buffer = new StreamReadBuffer(baseStream, minimalRead); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (_buffer != null) { _buffer.Dispose(); _buffer = null; } if (CloseBaseStream) { _baseStream.Close(); } } }