internal static bool IsGenericList(Type instanceType) { if (!instanceType.IsGenericType) { return false; } if (typeof(IList).IsAssignableFrom(instanceType)) { return true; } Type[] genericArgs = instanceType.GetGenericArguments(); if (genericArgs.Length == 0) { return false; } Type listType = typeof(IList<>).MakeGenericType(genericArgs[0]); return listType.IsAssignableFrom(instanceType); }
public override bool CanConvert(Type desiredType, Type inputType, object input, out bool exactMatch) { exactMatch = input != null && inputType == desiredType; return(DataBinder.IsGenericList(desiredType)); }