public static void WriteSymbol(ByteBuffer buffer, Symbol value, bool smallEncoding)
{
if (value == null)
{
AmqpBitConverter.WriteUByte(buffer, FormatCode.Null);
}
else
{
byte[] data = Encoding.UTF8.GetBytes(value);
if (smallEncoding && data.Length <= byte.MaxValue)
{
AmqpBitConverter.WriteUByte(buffer, FormatCode.Symbol8);
AmqpBitConverter.WriteUByte(buffer, (byte)data.Length);
AmqpBitConverter.WriteBytes(buffer, data, 0, data.Length);
}
else
{
AmqpBitConverter.WriteUByte(buffer, FormatCode.Symbol32);
AmqpBitConverter.WriteUInt(buffer, (uint)data.Length);
AmqpBitConverter.WriteBytes(buffer, data, 0, data.Length);
}
}
}