IrcDotNet.CircularBufferStream.Read C# (CSharp) Method

Read() public method

public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
return int
        public override int Read(byte[] buffer, int offset, int count)
        {
            // Read block of bytes from circular buffer, wrapping around when necessary.
            int totalReadCount = 0;
            int readCount;
            count = Math.Min(buffer.Length - offset, count);
            while ((readCount = Math.Min(count, (int)(Length))) > 0)
            {
                if (readCount > this.buffer.Length - readPosition)
                {
                    readCount = (int)(this.buffer.Length - readPosition);
                }
                System.Buffer.BlockCopy(this.buffer, (int)this.readPosition, buffer, offset, readCount);
                this.readPosition = (this.readPosition + readCount) % this.buffer.Length;
                offset += readCount;
                count = Math.Min(buffer.Length - offset, count);
                totalReadCount += readCount;
            }
            return totalReadCount;
        }
    }