public BufferedStream(Stream stream, int bufferSize)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (bufferSize <= 0)
throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(bufferSize)));
_stream = stream;
_bufferSize = bufferSize;
// Allocate _buffer on its first use - it will not be used if all reads
// & writes are greater than or equal to buffer size.
if (!_stream.CanRead && !_stream.CanWrite)
throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed);
}