NoMethodOnType() static private method

static private NoMethodOnType ( string name, object type ) : Exception
name string
type object
return Exception
Example #1
0
        internal static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection <Expression> args, Type[] typeArgs)
        {
            MethodInfo[] methods = type.GetStaticMethods().Where(m => m.Name == name).ToArray();
            if (methods.Length == 0)
            {
                throw Error.NoMethodOnType(name, type);
            }
            MethodInfo mi = methods.FirstOrDefault(m => ArgsMatch(m, args, typeArgs));

            if (mi == null)
            {
                throw Error.NoMethodOnTypeMatchingArguments(name, type);
            }
            if (typeArgs != null)
            {
                return(mi.MakeGenericMethod(typeArgs));
            }
            return(mi);
        }
Example #2
0
 internal static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection <Expression> args, Type[] typeArgs)
 {
     using (IEnumerator <MethodInfo> en = type.GetStaticMethods().Where(m => m.Name == name).GetEnumerator())
     {
         if (!en.MoveNext())
         {
             throw Error.NoMethodOnType(name, type);
         }
         do
         {
             MethodInfo mi = en.Current;
             if (ArgsMatch(mi, args, typeArgs))
             {
                 return((typeArgs != null) ? mi.MakeGenericMethod(typeArgs) : mi);
             }
         } while (en.MoveNext());
     }
     throw Error.NoMethodOnTypeMatchingArguments(name, type);
 }