System.Linq.QueryableTransformer.GetComparableType C# (CSharp) Метод

GetComparableType() статический приватный Метод

static private GetComparableType ( Type type ) : Type
type System.Type
Результат System.Type
		static Type GetComparableType (Type type)
		{
			if (type.IsGenericInstanceOf (typeof (IQueryable<>)))
				type = typeof (IEnumerable<>).MakeGenericTypeFrom (type);
			else if (type.IsGenericInstanceOf (typeof (IOrderedQueryable<>)))
				type = typeof (IOrderedEnumerable<>).MakeGenericTypeFrom (type);
			else if (type.IsGenericInstanceOf (typeof (Expression<>)))
				type = type.GetFirstGenericArgument ();
			else if (type == typeof (IQueryable))
				type = typeof (IEnumerable);

			return type;
		}
	}

Usage Example

 private static bool MethodMatch(MethodInfo candidate, MethodInfo method)
 {
     if (candidate.Name != method.Name)
     {
         return(false);
     }
     if (!QueryableTransformer.HasExtensionAttribute(candidate))
     {
         return(false);
     }
     Type[] parameterTypes = method.GetParameterTypes();
     if (parameterTypes.Length != candidate.GetParameters().Length)
     {
         return(false);
     }
     if (method.IsGenericMethod)
     {
         if (!candidate.IsGenericMethod)
         {
             return(false);
         }
         if (candidate.GetGenericArguments().Length != method.GetGenericArguments().Length)
         {
             return(false);
         }
         candidate = candidate.MakeGenericMethodFrom(method);
     }
     if (!QueryableTransformer.TypeMatch(candidate.ReturnType, method.ReturnType))
     {
         return(false);
     }
     Type[] parameterTypes2 = candidate.GetParameterTypes();
     if (parameterTypes2[0] != QueryableTransformer.GetComparableType(parameterTypes[0]))
     {
         return(false);
     }
     for (int i = 1; i < parameterTypes2.Length; i++)
     {
         if (!QueryableTransformer.TypeMatch(parameterTypes2[i], parameterTypes[i]))
         {
             return(false);
         }
     }
     return(true);
 }
All Usage Examples Of System.Linq.QueryableTransformer::GetComparableType