public TypeReference ImportType(Type type, IGenericContext context, ImportGenericType import_type) { if (IsTypeSpecification(type) || ImportOpenGenericType(type, import_type)) { return(ImportTypeSpecification(type, context)); } var reference = new TypeReference( string.Empty, type.Name, ImportScope(type.Assembly), type.IsValueType); reference.etype = ImportElementType(type); reference.module = module; if (IsNestedType(type)) { reference.DeclaringType = ImportType(type.DeclaringType, context); } else { reference.Namespace = type.Namespace; } if (type.IsGenericType) { ImportGenericParameters(reference, type.GetGenericArguments()); } return(reference); }
static bool ImportOpenGenericType(Type type, ImportGenericType import_type) { return(type.IsGenericType && type.IsGenericTypeDefinition && import_type == ImportGenericType.OpenType); }