MongoDB.GridFS.GridStream.Read C# (CSharp) Метод

Read() публичный Метод

public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
Результат int
        public override int Read(byte[] buffer, int offset, int count)
        {
            var end = Math.Min(_position + offset + count, _fileInfo.Length);

              var nRead = 0;
              var bufOffset = offset;
              var totalRead = 0;

              while (_position < end)
              {
            Seek(_position, SeekOrigin.Begin);
            var nToRead = Math.Min((int)(end - _position), _buffer.Capacity - (int)_buffer.Position);
            nRead = _buffer.Read(buffer, bufOffset, Math.Min(nToRead, count));
            count -= nRead;
            bufOffset += nRead;
            totalRead += nRead;
            _position += nRead;
              }
              return totalRead;
        }