private Type ReadType(Stream stream)
{
var firstByte = stream.ReadByte();
if ((firstByte & 0x80) == 0)
{
// use type alias
var b1 = stream.ReadByte();
var b2 = stream.ReadByte();
var b3 = stream.ReadByte();
var typeAlias = ((int)(firstByte) << 24) | ((int)(b1) << 16) | ((int)(b2) << 8) | ((int)(b3));
return _typeTable.GetType(typeAlias);
}
else
{
// use type assembly qualified name
stream.Position = stream.Position - 1;
var length = stream.Read7BitEncodedInt();
length -= 0x80;
var bytes = new byte[length];
stream.Read(bytes, 0, length);
var typeName = Encoding.UTF8.GetString(bytes);
return Type.GetType(typeName);
}
}
}