public static bool IsGenericCollection(this Type referenceType)
{
if (!referenceType.IsGenericType)
{
return false;
}
var enumerableType = typeof(IEnumerable<>).MakeGenericType(referenceType.GetGenericArguments());
var interfaces = referenceType.GetInterfaces();
return interfaces.Contains(enumerableType);
}