public override int GetObjectEncodeSize(object value, bool arrayEncoding) { if (arrayEncoding) { return(FixedWidth.UInt + Encoding.UTF8.GetByteCount((string)value)); } else { return(StringEncoding.GetEncodeSize((string)value)); } }
public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer) { if (arrayEncoding) { StringEncoding.Encode(Encoding.UTF8.GetBytes((string)value), FixedWidth.UInt, buffer); } else { StringEncoding.Encode((string)value, buffer); } }
public static void Encode(string value, ByteBuffer buffer) { if (value == null) { AmqpEncoding.EncodeNull(buffer); } else { byte[] encodedData = Encoding.UTF8.GetBytes(value); int encodeWidth = AmqpEncoding.GetEncodeWidthBySize(encodedData.Length); AmqpBitConverter.WriteUByte(buffer, encodeWidth == FixedWidth.UByte ? FormatCode.String8Utf8 : FormatCode.String32Utf8); StringEncoding.Encode(encodedData, encodeWidth, buffer); } }