示例#1
0
 public override ByteBuffer put(ByteBuffer src)
 {
     if (src is HeapByteBuffer)
     {
         if (src == this)
             throw new ArgumentException();
         var sb = (HeapByteBuffer) src;
         int n = sb.remaining();
         if (n > remaining())
             throw new BufferOverflowException();
         Array.Copy(sb.hb, sb.ix(sb.position()),
                    hb, ix(position()), n);
         sb.position(sb.position() + n);
         position(position() + n);
     }
     else if (src.isDirect())
     {
         int n = src.remaining();
         if (n > remaining())
             throw new BufferOverflowException();
         src.get(hb, ix(position()), n);
         position(position() + n);
     }
     else
     {
         base.put(src);
     }
     return this;
 }