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); } } }
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); } } }
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); }