public ManagedType Find (Type type)
{
ManagedType info;
ManagedType parent;
if (types.TryGetValue (type, out info))
return info;
Type typedef = type;
if (typedef.IsGenericType) {
typedef = typedef.GetGenericTypeDefinition();
if (types.TryGetValue (typedef, out info))
return info;
}
if (typedef.BaseType == null) {
parent = null;
} else if (typedef.BaseType == typeof (System.ValueType)) {
parent = Find (typeof (System.Object));
} else {
parent = Find (typedef.BaseType);
}
Type[] interfaces = type.GetInterfaces ();
ManagedType[] interface_types = new ManagedType[interfaces.Length];
for (int i = 0; i < interfaces.Length; i ++)
interface_types[i] = Find (interfaces[i]);
return RegisterType (type, parent, interface_types);
}