private static Type GetEnumerableUnderlyingType(Type type) { var types = type.GetInterfaces().ToList(); types.Add(type); var enumerable = types.FirstOrDefault(i => i.IsGenericType && TypeUtils.Equals(typeof(IEnumerable <>), i.GetGenericTypeDefinition())); if (enumerable != null) { return(enumerable.GenericTypeArguments.FirstOrDefault()); } return(null); }
private static bool IsDictionaryInterface(Type type) { return(type.IsGenericType && (TypeUtils.Equals(type.GetGenericTypeDefinition(), typeof(IDictionary <,>)) || TypeUtils.Equals(type.GetGenericTypeDefinition(), typeof(IReadOnlyDictionary <,>)))); }