public BoundedByteBufferSend(ByteBuffer buffer)
        {
            this.Buffer = buffer;

            if (buffer.Remaining() > int.MaxValue - this.sizeBuffer.Limit())
            {
                throw new ArgumentException("Attempt to create a bounded buffer of " + buffer.Length + "bytes, but the maximum allowable size for a bounded buffer is " + (int.MaxValue - this.sizeBuffer.Length));
            }

            this.sizeBuffer.PutInt(buffer.Limit());
            this.sizeBuffer.Rewind();
        }
Esempio n. 2
0
        protected bool Equals(ByteBuffer other)
        {
            if (this.Remaining() != other.Remaining())
            {
                return false;
            }

            var p = (int)this.Position;

            for (int i = this.Limit() - 1, j = other.Limit() - 1; i >= p; i--, j--)
            {
                if (!Equals(this.Get(i), other.Get(j)))
                {
                    return false;
                }
            }

            return true;
        }