Castle.Components.Binder.DataBinder.IsGenericList C# (CSharp) Method

IsGenericList() static private method

static private IsGenericList ( Type instanceType ) : bool
instanceType System.Type
return bool
		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);
		}

Usage Example

コード例 #1
0
 public override bool CanConvert(Type desiredType, Type inputType, object input, out bool exactMatch)
 {
     exactMatch = input != null && inputType == desiredType;
     return(DataBinder.IsGenericList(desiredType));
 }