Example #1
0
        private MethodInfo[] resolveExecuteMethods()
        {
            List <MethodInfo> result = new List <MethodInfo>();

            ListMethodsFilter filter = delegate(MethodInfo method)
            {
                if (method.Name != "Execute")
                {
                    return(false);
                }

                if (method.IsAbstract)
                {
                    return(false);
                }

                return(method.ReturnType == typeof(void) || method.ReturnType == typeof(bool));
            };

            Type type = GetCommandType();

            while (type != null)
            {
                ClassUtils.ListInstanceMethods(result, type, filter);
                type = type.BaseType;
            }

            return(result.ToArray());
        }
Example #2
0
        public static List <MethodInfo> ListMethods(List <MethodInfo> outList, Type type, ListMethodsFilter filter, BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
        {
            MethodInfo[] methods = type.GetMethods(flags);

            if (filter == null)
            {
                outList.AddRange(methods);
                return(outList);
            }

            foreach (MethodInfo m in methods)
            {
                if (filter(m))
                {
                    outList.Add(m);
                }
            }
            return(outList);
        }
Example #3
0
 public static List <MethodInfo> ListInstanceMethods(Type type, ListMethodsFilter filter)
 {
     return(ListInstanceMethods(new List <MethodInfo>(), type, filter));
 }
Example #4
0
 public static List <MethodInfo> ListInstanceMethods(List <MethodInfo> outList, Type type, ListMethodsFilter filter)
 {
     return(ListMethods(outList, type, filter, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
 }