internal static ClassType GetClassType(Type type) { Debug.Assert(type != null); if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = Nullable.GetUnderlyingType(type); } if (DefaultConverters.IsValueConvertable(type)) { return(ClassType.Value); } if (typeof(IDictionary).IsAssignableFrom(type) || (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(IDictionary <,>) || type.GetGenericTypeDefinition() == typeof(IReadOnlyDictionary <,>)))) { return(ClassType.Dictionary); } if (typeof(IEnumerable).IsAssignableFrom(type)) { return(ClassType.Enumerable); } if (type == typeof(object)) { return(ClassType.Unknown); } return(ClassType.Object); }
public static ClassType GetClassType(Type type) { Debug.Assert(type != null); if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = Nullable.GetUnderlyingType(type); } if (DefaultConverters.IsValueConvertable(type)) { return(ClassType.Value); } if (DefaultImmutableDictionaryConverter.IsImmutableDictionary(type) || IsDeserializedByConstructingWithIDictionary(type)) { return(ClassType.IDictionaryConstructible); } if (typeof(IDictionary).IsAssignableFrom(type) || (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(IDictionary <,>) || type.GetGenericTypeDefinition() == typeof(IReadOnlyDictionary <,>)))) { return(ClassType.Dictionary); } if (IsKeyValuePair(type)) { return(ClassType.KeyValuePair); } if (typeof(IEnumerable).IsAssignableFrom(type)) { return(ClassType.Enumerable); } if (type == typeof(object)) { return(ClassType.Unknown); } return(ClassType.Object); }