public Type ReadType(BinaryReader reader, TypeTag code)
{
switch (code)
{
case TypeTag.PrimitiveType:
return(BinaryCommon.GetTypeFromCode(reader.ReadByte()));
case TypeTag.String:
return(typeof(string));
case TypeTag.ObjectType:
return(typeof(object));
case TypeTag.RuntimeType:
{
string name = reader.ReadString();
#if NET_2_0
// map MS.NET's System.RuntimeType to System.MonoType
if (_context.State == StreamingContextStates.Remoting)
{
if (name == "System.RuntimeType")
{
return(typeof(MonoType));
}
else if (name == "System.RuntimeType[]")
{
return(typeof(MonoType[]));
}
}
#endif
Type t = Type.GetType(name);
if (t != null)
{
return(t);
}
throw new SerializationException(String.Format("Could not find type '{0}'.", name));
}
case TypeTag.GenericType:
{
string name = reader.ReadString();
long asmid = (long)reader.ReadUInt32();
return(GetDeserializationType(asmid, name));
}
case TypeTag.ArrayOfObject:
return(typeof(object[]));
case TypeTag.ArrayOfString:
return(typeof(string[]));
case TypeTag.ArrayOfPrimitiveType:
Type elementType = BinaryCommon.GetTypeFromCode(reader.ReadByte());
return(Type.GetType(elementType.FullName + "[]"));
default:
throw new NotSupportedException("Unknow type tag");
}
}