ReadCount() public static method

public static ReadCount ( ByteBuffer buffer, FormatCode formatCode, FormatCode formatCode8, FormatCode formatCode32, int &count ) : void
buffer ByteBuffer
formatCode FormatCode
formatCode8 FormatCode
formatCode32 FormatCode
count int
return void
Exemplo n.º 1
0
        public static ArraySegment <byte> Decode(ByteBuffer buffer, FormatCode formatCode, bool copy)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(AmqpConstants.NullBinary);
            }

            int count;

            AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Binary8, FormatCode.Binary32, out count);
            if (count == 0)
            {
                return(AmqpConstants.EmptyBinary);
            }
            else
            {
                ArraySegment <byte> value;
                if (copy)
                {
                    byte[] valueBuffer = new byte[count];
                    Buffer.BlockCopy(buffer.Buffer, buffer.Offset, valueBuffer, 0, count);
                    value = new ArraySegment <byte>(valueBuffer, 0, count);
                }
                else
                {
                    value = new ArraySegment <byte>(buffer.Buffer, buffer.Offset, count);
                }

                buffer.Complete(count);
                return(value);
            }
        }
Exemplo n.º 2
0
        public static AmqpSymbol Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(new AmqpSymbol());
            }

            int count;

            AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Symbol8, FormatCode.Symbol32, out count);
            string value = Encoding.ASCII.GetString(buffer.Buffer, buffer.Offset, count);

            buffer.Complete(count);

            return(new AmqpSymbol(value));
        }