Ejemplo n.º 1
0
        public static IChannelBuffer DirectBuffer(int capacity)
        {
            if (capacity == 0)
            {
                return(EmptyBuffer);
            }

            IChannelBuffer buffer = new ByteBufferBackedChannelBuffer(
                Unpooled.Buffer(capacity));

            buffer.Clear();
            return(buffer);
        }
Ejemplo n.º 2
0
        public override void SetBytes(int index, IChannelBuffer src, int srcIndex, int length)
        {
            if (src is ByteBufferBackedChannelBuffer)
            {
                ByteBufferBackedChannelBuffer bbsrc = (ByteBufferBackedChannelBuffer)src;
                IByteBuffer data = bbsrc.Buffer.Duplicate();

                data.Slice(srcIndex, length);
                SetBytes(index, data);
            }
            else if (Buffer.HasArray)
            {
                src.GetBytes(srcIndex, Buffer.Array, index + Buffer.ArrayOffset, length);
            }
            else
            {
                src.GetBytes(srcIndex, this, index, length);
            }
        }
Ejemplo n.º 3
0
 public ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer)
 {
     Buffer = buffer.Buffer;
     SetIndex(buffer.ReaderIndex, buffer.WriterIndex);
 }