private void WriteType(Stream stream, Type type)
{
var messageTypeAlias = _typeTable.GetAlias(type);
if (messageTypeAlias != 0)
{
// Write big endian
var bytes = BitConverter.GetBytes(messageTypeAlias);
stream.WriteByte(bytes[3]);
stream.WriteByte(bytes[2]);
stream.WriteByte(bytes[1]);
stream.WriteByte(bytes[0]);
}
else
{
// Write string with length 0x80 for making msb of first byte set
var name = type.AssemblyQualifiedName;
var bytes = Encoding.UTF8.GetBytes(name);
stream.Write7BitEncodedInt(0x80 + bytes.Length);
stream.Write(bytes, 0, bytes.Length);
}
}