コード例 #1
0
ファイル: ByteEncoding.cs プロジェクト: xinchen10/azure-amqp
        public static sbyte?Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(null);
            }

            return(AmqpBitConverter.ReadByte(buffer));
        }
コード例 #2
0
 public static sbyte ReadByte(ByteBuffer buffer, byte formatCode)
 {
     if (formatCode == FormatCode.Byte)
     {
         return(AmqpBitConverter.ReadByte(buffer));
     }
     else
     {
         throw DecodeException(formatCode, buffer.Offset);
     }
 }
コード例 #3
0
ファイル: IntEncoding.cs プロジェクト: xinchen10/azure-amqp
        public static int?Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(null);
            }

            VerifyFormatCode(formatCode, buffer.Offset, FormatCode.Int, FormatCode.SmallInt);
            return(formatCode == FormatCode.SmallInt ?
                   AmqpBitConverter.ReadByte(buffer) :
                   AmqpBitConverter.ReadInt(buffer));
        }
コード例 #4
0
        public static long?Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(null);
            }

            VerifyFormatCode(formatCode, buffer.Offset, FormatCode.Long, FormatCode.SmallLong);
            return(formatCode == FormatCode.SmallLong ?
                   AmqpBitConverter.ReadByte(buffer) :
                   AmqpBitConverter.ReadLong(buffer));
        }
コード例 #5
0
 public static long ReadLong(ByteBuffer buffer, byte formatCode)
 {
     if (formatCode == FormatCode.SmallLong)
     {
         return(AmqpBitConverter.ReadByte(buffer));
     }
     else if (formatCode == FormatCode.Long)
     {
         return(AmqpBitConverter.ReadLong(buffer));
     }
     else
     {
         throw DecodeException(formatCode, buffer.Offset);
     }
 }
コード例 #6
0
 public static int ReadInt(ByteBuffer buffer, byte formatCode)
 {
     if (formatCode == FormatCode.SmallInt)
     {
         return(AmqpBitConverter.ReadByte(buffer));
     }
     else if (formatCode == FormatCode.Int)
     {
         return(AmqpBitConverter.ReadInt(buffer));
     }
     else
     {
         throw DecodeException(formatCode, buffer.Offset);
     }
 }
コード例 #7
0
        public void Can_Encode_Int_Without_Boxing_Using_Generic_DecodeObject()
        {
            var buffer   = new ByteBuffer(1024, true);
            var instance = new TestCompositeClass();

            instance.IntValue = randNum.Next(300, 1000);

            // compile lambda expression
            var compiled = CompileGenericPropertyEncodeExpression(typeof(TestCompositeClass), "IntValue");

            // execute
            compiled(instance, buffer);

            // assert
            var formatCode = AmqpBitConverter.ReadByte(buffer);

            Assert.AreEqual(FormatCode.Int, formatCode);
            var value = AmqpBitConverter.ReadInt(buffer);

            Assert.AreEqual(instance.IntValue, value);
        }
コード例 #8
0
        public void TestMethod_AmqpBitConverter()
        {
            ByteBuffer buffer = new ByteBuffer(128, true);

            AmqpBitConverter.WriteByte(buffer, 0x22);
            AmqpBitConverter.WriteByte(buffer, -0x22);

            AmqpBitConverter.WriteUByte(buffer, 0x22);
            AmqpBitConverter.WriteUByte(buffer, 0xB2);

            AmqpBitConverter.WriteShort(buffer, 0x22B7);
            AmqpBitConverter.WriteShort(buffer, -0x22B7);

            AmqpBitConverter.WriteUShort(buffer, 0x22B7);
            AmqpBitConverter.WriteUShort(buffer, 0xC2B7);

            AmqpBitConverter.WriteInt(buffer, 0x340da287);
            AmqpBitConverter.WriteInt(buffer, -0x340da287);

            AmqpBitConverter.WriteUInt(buffer, 0x340da287);
            AmqpBitConverter.WriteUInt(buffer, 0xF40da287);

            AmqpBitConverter.WriteLong(buffer, 0x5d00BB9A340da287);
            AmqpBitConverter.WriteLong(buffer, -0x5d00BB9A340da287);

            AmqpBitConverter.WriteULong(buffer, 0x5d00BB9A340da287);
            AmqpBitConverter.WriteULong(buffer, 0xad00BB9A340da287);

            AmqpBitConverter.WriteFloat(buffer, 12344.4434F);
            AmqpBitConverter.WriteFloat(buffer, -12344.4434F);

            AmqpBitConverter.WriteDouble(buffer, 39432123244.44352334);
            AmqpBitConverter.WriteDouble(buffer, -39432123244.44352334);

            Guid uuid = Guid.NewGuid();

            AmqpBitConverter.WriteUuid(buffer, uuid);

            sbyte b  = AmqpBitConverter.ReadByte(buffer);
            sbyte b2 = AmqpBitConverter.ReadByte(buffer);

            byte ub  = AmqpBitConverter.ReadUByte(buffer);
            byte ub2 = AmqpBitConverter.ReadUByte(buffer);

            short s  = AmqpBitConverter.ReadShort(buffer);
            short s2 = AmqpBitConverter.ReadShort(buffer);

            ushort us  = AmqpBitConverter.ReadUShort(buffer);
            ushort us2 = AmqpBitConverter.ReadUShort(buffer);

            int i  = AmqpBitConverter.ReadInt(buffer);
            int i2 = AmqpBitConverter.ReadInt(buffer);

            uint ui  = AmqpBitConverter.ReadUInt(buffer);
            uint ui2 = AmqpBitConverter.ReadUInt(buffer);

            long l  = AmqpBitConverter.ReadLong(buffer);
            long l2 = AmqpBitConverter.ReadLong(buffer);

            ulong ul  = AmqpBitConverter.ReadULong(buffer);
            ulong ul2 = AmqpBitConverter.ReadULong(buffer);

            float f  = AmqpBitConverter.ReadFloat(buffer);
            float f2 = AmqpBitConverter.ReadFloat(buffer);

            double d  = AmqpBitConverter.ReadDouble(buffer);
            double d2 = AmqpBitConverter.ReadDouble(buffer);

            Guid uuid2 = AmqpBitConverter.ReadUuid(buffer);
        }