public static string generating_type(object Current) // Name of Current object's generating type // (type of which it is a direct instance) { string Result = null; RT_CLASS_TYPE l_type; EIFFEL_TYPE_INFO l_current = Current as EIFFEL_TYPE_INFO; if (Current == null) { generate_call_on_void_target_exception(); } else if (l_current != null) { l_type = l_current.____type(); if (l_type == null) { // Not a generic class. l_type = new RT_CLASS_TYPE(Type.GetTypeHandle(Current)); } Result = l_type.type_name(); } else { Result = Current.GetType().FullName; } return(Result); }
public static RT_TYPE load_type_of_object(object an_obj) // Given an Eiffel object `an_obj' extract its type information. { RT_GENERIC_TYPE l_gen_type; RT_CLASS_TYPE Result; EIFFEL_TYPE_INFO l_obj = an_obj as EIFFEL_TYPE_INFO; if (l_obj != null) { l_gen_type = l_obj.____type(); } else { l_gen_type = null; } if (l_gen_type == null) { // It is not an Eiffel generic type or it is a .NET type, so we can simply // find its type through Reflection and then creates a RT_CLASS_TYPE object. // Note that .NET generic types are treated as non-generic. Result = new RT_CLASS_TYPE(); Result.set_type(an_obj.GetType().TypeHandle); } else { // It is a generic type, so we can simply find its type through // its RT_GENERIC_TYPE. Result = l_gen_type; } return(Result); }
/* * feature -- Object creation */ public static object create_type(RT_CLASS_TYPE a_type) // Create new instance of `a_type'. { // Create new object of type `a_type'. // Properly initializes `Result'. return(GENERIC_CONFORMANCE.create_instance (Type.GetTypeFromHandle(a_type.type), a_type as RT_GENERIC_TYPE)); }