예제 #1
0
 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;
 }
예제 #2
0
        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;
        }
예제 #3
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         if (_buffer != null)
         {
             _buffer.Dispose();
             _buffer = null;
         }
         if (!_leaveOpen)
         {
             _baseStream.Dispose();
         }
     }
 }
예제 #4
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         if (_buffer != null)
         {
             _buffer.Dispose();
             _buffer = null;
         }
         if (CloseBaseStream)
         {
             _baseStream.Flush();
             _baseStream.Dispose();
         }
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                if (_buffer != null)
                {
                    _buffer.Dispose();
                    _buffer = null;
                }

                if (CloseBaseStream)
                {
                    _baseStream.Close();
                }
            }
        }