Пример #1
0
        public override MemoryStream[] NioBuffers(int index, int length)
        {
            CheckIndex(index, length);
            if (length == 0)
            {
                return(new MemoryStream[0]); // EMPTY_BYTE_BUFFERS
            }

            var buffers = new List <MemoryStream>(_components.Count);
            int i       = ToComponentIndex(index);

            while (length > 0)
            {
                Component c           = _components[i];
                ByteBuf   s           = c._buf;
                int       adjustment  = c._offset;
                int       localLength = Math.Min(length, s.Capacity - (index - adjustment));
                switch (s.NioBufferCount())
                {
                case 0:
                    throw new NotSupportedException();

                case 1:
                    buffers.Add(s.NioBuffer(index - adjustment, localLength));
                    break;

                default:
                    buffers.AddRange(s.NioBuffers(index - adjustment, localLength));
                    break;
                }

                index  += localLength;
                length -= localLength;
                i++;
            }

            return(buffers.ToArray());
        }
Пример #2
0
 public override MemoryStream[] NioBuffers(int index, int length)
 {
     return(_buffer.NioBuffers(index, length));
 }
Пример #3
0
 public override MemoryStream[] NioBuffers(int index, int length)
 {
     CheckIndex(index, length);
     return(_buffer.NioBuffers(index + _adjustment, length));
 }