コード例 #1
0
        public ByteBufferReader(ReadOnlySequence <byte> buffer)
        {
            _currentSpanIndex = 0;
            _consumed         = 0;
            _sequence         = buffer;
            _currentPosition  = buffer.Start;
            _length           = -1;

            ByteBufferReaderHelper.GetFirstSpan(buffer, out ReadOnlySpan <byte> first, out _nextPosition);
            _currentSpan = first;
            _moreData    = (uint)first.Length > 0u;

            if (!buffer.IsSingleSegment && !_moreData)
            {
                _moreData = true;
                GetNextSpan();
            }
        }
コード例 #2
0
        /// <summary>Create a <see cref="ByteBufferReader" /> over the given <see cref="IByteBuffer"/>.</summary>
        public ByteBufferReader(IByteBuffer buffer)
        {
            _origin = buffer;
            var sequence = buffer.UnreadSequence;

            _currentSpanIndex = 0;
            _consumed         = 0;
            _sequence         = sequence;
            _currentPosition  = sequence.Start;
            _length           = -1;

            ByteBufferReaderHelper.GetFirstSpan(sequence, out ReadOnlySpan <byte> first, out _nextPosition);
            _currentSpan = first;
            _moreData    = (uint)first.Length > 0u;

            if (!sequence.IsSingleSegment && !_moreData)
            {
                _moreData = true;
                GetNextSpan();
            }
        }