コード例 #1
0
ファイル: ULongEncoding.cs プロジェクト: xinchen10/azure-amqp
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (arrayEncoding)
     {
         AmqpBitConverter.WriteULong(buffer, (ulong)value);
     }
     else
     {
         ULongEncoding.Encode((ulong)value, buffer);
     }
 }
コード例 #2
0
 public static void WriteULong(ByteBuffer buffer, ulong value, bool smallEncoding)
 {
     if (!smallEncoding || value > byte.MaxValue)
     {
         AmqpBitConverter.WriteUByte(buffer, FormatCode.ULong);
         AmqpBitConverter.WriteULong(buffer, value);
     }
     else if (value == 0)
     {
         AmqpBitConverter.WriteUByte(buffer, FormatCode.ULong0);
     }
     else if (value <= byte.MaxValue)
     {
         AmqpBitConverter.WriteUByte(buffer, FormatCode.SmallULong);
         AmqpBitConverter.WriteUByte(buffer, (byte)value);
     }
 }
コード例 #3
0
            public override void WriteObject(ByteBuffer buffer, object graph)
            {
                if (graph == null)
                {
                    AmqpEncoding.EncodeNull(buffer);
                    return;
                }
                if (!this.WriteFormatCode(buffer))
                {
                    return;
                }
                int writePos = buffer.WritePos;

                AmqpBitConverter.WriteULong(buffer, (ulong)0);
                int num = this.WriteMembers(buffer, graph);

                AmqpBitConverter.WriteUInt(buffer.Buffer, writePos, (uint)(buffer.WritePos - writePos - 4));
                AmqpBitConverter.WriteUInt(buffer.Buffer, writePos + 4, (uint)num);
            }
コード例 #4
0
            public override void WriteObject(ByteBuffer buffer, object graph)
            {
                if (graph == null)
                {
                    Encoder.WriteObject(buffer, null);
                    return;
                }

                if (!this.WriteFormatCode(buffer))
                {
                    return;
                }

                int pos = buffer.WritePos;                  // remember the current position

                AmqpBitConverter.WriteULong(buffer, 0);     // reserve space for size and count

                int count = this.WriteMembers(buffer, graph);

                AmqpBitConverter.WriteInt(buffer.Buffer, pos, buffer.WritePos - pos - FixedWidth.UInt);
                AmqpBitConverter.WriteInt(buffer.Buffer, pos + FixedWidth.UInt, count);
            }
コード例 #5
0
        internal override void EncodeValue(ByteBuffer buffer)
        {
            int count = 0;
            int temp  = this.fields;

            while (temp > 0)
            {
                count++;
                temp <<= 1;
            }

            count = 32 - count;
            if (count == 0)
            {
                AmqpBitConverter.WriteUByte(buffer, FormatCode.List0);
            }
            else
            {
                int pos = buffer.WritePos;
                AmqpBitConverter.WriteUByte(buffer, 0);
                AmqpBitConverter.WriteULong(buffer, 0);
                for (int i = 0; i < count; i++)
                {
                    if ((this.fields & (1 << i)) > 0)
                    {
                        this.WriteField(buffer, i);
                    }
                    else
                    {
                        AmqpBitConverter.WriteUByte(buffer, FormatCode.Null);
                    }
                }

                Encoder.WriteListCount(buffer, pos, count, true);
            }
        }
コード例 #6
0
ファイル: ULongEncoding.cs プロジェクト: xinchen10/azure-amqp
 public static void Encode(ulong?value, ByteBuffer buffer)
 {
     if (value.HasValue)
     {
         if (value == 0)
         {
             AmqpBitConverter.WriteUByte(buffer, FormatCode.ULong0);
         }
         else if (value <= byte.MaxValue)
         {
             AmqpBitConverter.WriteUByte(buffer, FormatCode.SmallULong);
             AmqpBitConverter.WriteUByte(buffer, (byte)value.Value);
         }
         else
         {
             AmqpBitConverter.WriteUByte(buffer, FormatCode.ULong);
             AmqpBitConverter.WriteULong(buffer, value.Value);
         }
     }
     else
     {
         AmqpEncoding.EncodeNull(buffer);
     }
 }
コード例 #7
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);
        }