public static MethodInfo [] GetMethods(this Type t, string name, BindingFlags flags) { MethodInfo[] res = CacheReflection.GetMethodInfoCache(t, name, flags); if (res != null) { return(res); } res = t.GetMethods(flags).Where(m => m.Name == name).ToArray(); CacheReflection.UpdateMethodInfoCache(t, name, flags, res); return(res); }
public static bool HasMethod(this Type t, string name) { BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; MethodInfo[] res = CacheReflection.GetMethodInfoCache(t, name, flags); if (res == null) { res = t.GetMethods(flags).Where(m => m.Name == name).ToArray(); CacheReflection.UpdateMethodInfoCache(t, name, flags, res); } for (int i = 0; i < res.Length; i++) { if (res[i].Name == name) { return(true); } } return(false); }