Exemplo n.º 1
0
        private static unsafe void EncodeValue(decimal value, ByteBuffer buffer)
        {
            int[] bits = decimal.GetBits(value);
            int   num  = bits[0];
            int   num1 = bits[1];
            int   num2 = bits[2];
            int   num3 = bits[3];

            byte[] numArray   = new byte[16];
            byte * numPointer = (byte *)(&num3);
            int    num4       = 6176 - *(numPointer + 2);

            numArray[0]  = *(numPointer + 3);
            numArray[0]  = (byte)(numArray[0] | (byte)(num4 >> 9));
            numArray[1]  = (byte)((num4 & 127) << 1);
            numArray[2]  = 0;
            numArray[3]  = 0;
            numPointer   = (byte *)(&num2);
            numArray[4]  = *(numPointer + 3);
            numArray[5]  = *(numPointer + 2);
            numArray[6]  = *(numPointer + 1);
            numArray[7]  = *numPointer;
            numPointer   = (byte *)(&num1);
            numArray[8]  = *(numPointer + 3);
            numArray[9]  = *(numPointer + 2);
            numArray[10] = *(numPointer + 1);
            numArray[11] = *numPointer;
            numPointer   = (byte *)(&num);
            numArray[12] = *(numPointer + 3);
            numArray[13] = *(numPointer + 2);
            numArray[14] = *(numPointer + 1);
            numArray[15] = *numPointer;
            AmqpBitConverter.WriteBytes(buffer, numArray, 0, (int)numArray.Length);
        }
Exemplo n.º 2
0
        public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
        {
            if (!arrayEncoding)
            {
                BinaryEncoding.Encode((ArraySegment <byte>)value, buffer);
                return;
            }
            ArraySegment <byte> nums = (ArraySegment <byte>)value;

            AmqpBitConverter.WriteUInt(buffer, (uint)nums.Count);
            AmqpBitConverter.WriteBytes(buffer, nums.Array, nums.Offset, nums.Count);
        }
Exemplo n.º 3
0
 private static void Encode(byte[] encodedData, int width, ByteBuffer buffer)
 {
     if (width != 1)
     {
         AmqpBitConverter.WriteUInt(buffer, (uint)encodedData.Length);
     }
     else
     {
         AmqpBitConverter.WriteUByte(buffer, (byte)((int)encodedData.Length));
     }
     AmqpBitConverter.WriteBytes(buffer, encodedData, 0, (int)encodedData.Length);
 }
Exemplo n.º 4
0
 public static void Encode(ArraySegment <byte> value, ByteBuffer buffer)
 {
     if (value.Array == null)
     {
         AmqpEncoding.EncodeNull(buffer);
         return;
     }
     if (AmqpEncoding.GetEncodeWidthBySize(value.Count) != 1)
     {
         AmqpBitConverter.WriteUByte(buffer, 176);
         AmqpBitConverter.WriteUInt(buffer, (uint)value.Count);
     }
     else
     {
         AmqpBitConverter.WriteUByte(buffer, 160);
         AmqpBitConverter.WriteUByte(buffer, (byte)value.Count);
     }
     AmqpBitConverter.WriteBytes(buffer, value.Array, value.Offset, value.Count);
 }