Пример #1
0
        public override ByteBuf Duplicate()
        {
            ByteBuf duplicate = _buffer.Slice(_adjustment, _length);

            duplicate.SetIndex(ReaderIndex, WriterIndex);
            return(duplicate);
        }
Пример #2
0
        private int AddComponent0(int cIndex, ByteBuf buffer)
        {
            CheckComponentIndex(cIndex);

            if (buffer == null)
            {
                throw new NullReferenceException("buffer");
            }

            int readableBytes = buffer.ReadableBytes;

            if (readableBytes == 0)
            {
                return(cIndex);
            }

            // No need to consolidate - just add a component to the list.
            var c = new Component(buffer.Slice());

            if (cIndex == _components.Count)
            {
                _components.Add(c);
                if (cIndex == 0)
                {
                    c._endOffset = readableBytes;
                }
                else
                {
                    Component prev = _components[cIndex - 1];
                    c._offset    = prev._endOffset;
                    c._endOffset = c._offset + readableBytes;
                }
            }
            else
            {
                _components.Insert(cIndex, c);
                UpdateComponentOffsets(cIndex);
            }
            return(cIndex);
        }
Пример #3
0
 public override ByteBuf Slice(int index, int length)
 {
     return(_buffer.Slice(index, length));
 }