示例#1
0
 private static void Encode(Array value, int width, int encodeSize, ByteBuffer buffer)
 {
     encodeSize = encodeSize - (1 + width);
     if (width != 1)
     {
         AmqpBitConverter.WriteUInt(buffer, (uint)encodeSize);
         AmqpBitConverter.WriteUInt(buffer, (uint)value.Length);
     }
     else
     {
         AmqpBitConverter.WriteUByte(buffer, (byte)encodeSize);
         AmqpBitConverter.WriteUByte(buffer, (byte)value.Length);
     }
     if (value.Length > 0)
     {
         object       obj      = value.GetValue(0);
         EncodingBase encoding = AmqpEncoding.GetEncoding(obj);
         AmqpBitConverter.WriteUByte(buffer, encoding.FormatCode);
         if (encoding.FormatCode == 0)
         {
             DescribedType describedType = (DescribedType)obj;
             AmqpEncoding.EncodeObject(describedType.Descriptor, buffer);
             AmqpBitConverter.WriteUByte(buffer, AmqpEncoding.GetEncoding(describedType.Value).FormatCode);
         }
         foreach (object obj1 in value)
         {
             encoding.EncodeObject(obj1, true, buffer);
         }
     }
 }
示例#2
0
        static void Encode(Array value, int width, int encodeSize, ByteBuffer buffer)
        {
            encodeSize -= (FixedWidth.FormatCode + width);
            if (width == FixedWidth.UByte)
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)encodeSize);
                AmqpBitConverter.WriteUByte(buffer, (byte)value.Length);
            }
            else
            {
                AmqpBitConverter.WriteUInt(buffer, (uint)encodeSize);
                AmqpBitConverter.WriteUInt(buffer, (uint)value.Length);
            }

            if (value.Length > 0)
            {
                object       firstItem = value.GetValue(0);
                EncodingBase encoding  = AmqpEncoding.GetEncoding(firstItem);
                AmqpBitConverter.WriteUByte(buffer, (byte)encoding.FormatCode);
                if (encoding.FormatCode == FormatCode.Described)
                {
                    DescribedType describedValue = (DescribedType)firstItem;
                    AmqpEncoding.EncodeObject(describedValue.Descriptor, buffer);
                    AmqpBitConverter.WriteUByte(buffer, (byte)AmqpEncoding.GetEncoding(describedValue.Value).FormatCode);
                }

                foreach (object item in value)
                {
                    encoding.EncodeObject(item, true, buffer);
                }
            }
        }
示例#3
0
        public static void EncodeObject(object value, ByteBuffer buffer)
        {
            if (value == null)
            {
                EncodeNull(buffer);
                return;
            }

            IAmqpSerializable serializable = value as IAmqpSerializable;

            if (serializable != null)
            {
                serializable.Encode(buffer);
                return;
            }

            EncodingBase encoding = GetEncoding(value);;

            encoding.EncodeObject(value, false, buffer);
        }