CqlSharp.Protocol.FrameReader.TryGetSegmentFromBuffer C# (CSharp) Method

TryGetSegmentFromBuffer() private method

Tries to get a array segment of specific size from the buffer.
private TryGetSegmentFromBuffer ( int size ) : bool
size int The size.
return bool
        private bool TryGetSegmentFromBuffer(int size)
        {
            if(_disposed)
                throw new ObjectDisposedException("FrameReader");

            //part of current buffer
            if(size <= _remainingInBuffer)
            {
                _lastReadSegment = new ArraySegment<byte>(_buffer, _position, size);
                _position += size;
                _remainingInBuffer -= size;
                return true;
            }

            return false;
        }