Example #1
0
        public static List <MethodInfo> ListActionMethods(object target)
        {
            List <MethodInfo> methods = new List <MethodInfo>();

            ClassUtils.ListMethods(methods, target.GetType(), IsValidActionMethod, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            return(methods);
        }
Example #2
0
        static MethodInfo ResolveMethod(object target, string methodName, Type paramType)
        {
            var methods = ClassUtils.ListInstanceMethods(target.GetType(), delegate(MethodInfo method)
            {
                if (method.Name != methodName)
                {
                    return(false);
                }

                var parameters = method.GetParameters();
                if (paramType == typeof(void))
                {
                    return(parameters.Length == 0);
                }

                return(parameters.Length == 1 && (parameters[0].ParameterType == paramType || parameters[0].ParameterType.IsSubclassOf(paramType)));
            });

            return(methods.Count == 1 ? methods[0] : null);
        }