public override int Read(byte[] buffer, int offset, int count)
{
this.ThrowIfDisposed();
if (this.readArray == this.bufferList.Count)
{
return 0;
}
int bytesRead = 0;
while (count > 0 && this.readArray < this.bufferList.Count)
{
ArraySegment<byte> segment = this.bufferList[this.readArray];
int bytesRemaining = segment.Count - this.readOffset;
int bytesToCopy = Math.Min(bytesRemaining, count);
Buffer.BlockCopy(segment.Array, segment.Offset + this.readOffset, buffer, offset, bytesToCopy);
this.Advance(bytesToCopy, segment.Count);
count -= bytesToCopy;
offset += bytesToCopy;
bytesRead += bytesToCopy;
}
return bytesRead;
}