public static MethodInfo GetGenericMethod(this CType ctype, string name, BindingFlags bindingAttr, string[] genericArguments, CType[] types) { if (types == null || types.Any(t => t == null)) { throw new ArgumentNullException("types"); } if (types.Length == 0) { return(ctype.GetGenericMethod(name, bindingAttr)); } var members = ctype.GetMember(name, bindingAttr).Where(m => m.MemberType == MemberTypes.Method && ((MethodInfo)m).IsGenericMethod).ToArray(); if (members.Length == 0) { return(null); } var methods = members.Cast <MethodInfo> ().Where(m => MatchParameters(m, genericArguments, types)).ToArray(); if (methods.Length == 0) { return(null); } if (methods.Length == 1) { return(methods[0]); } throw new AmbiguousMatchException("name is not unique", null); }