public static IChannelBuffer DirectBuffer(int capacity) { if (capacity == 0) { return(EmptyBuffer); } IChannelBuffer buffer = new ByteBufferBackedChannelBuffer( Unpooled.Buffer(capacity)); buffer.Clear(); return(buffer); }
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); } }
public ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer) { Buffer = buffer.Buffer; SetIndex(buffer.ReaderIndex, buffer.WriterIndex); }