Exemplo n.º 1
0
        /// <summary>
        /// 从控制器类型中获取功能信息集合
        /// </summary>
        /// <param name="types">控制器类型</param>
        /// <returns>功能信息集合</returns>
        protected virtual TFunction[] GetFunctions(Type[] types)
        {
            List <TFunction> functions = new List <TFunction>();

            foreach (Type controllerType in types.OrderBy(m => m.FullName))
            {
                TFunction controller = GetFunction(controllerType);
                if (controller == null)
                {
                    continue;
                }
                if (!ExistsFunction(functions, controller))
                {
                    functions.Add(controller);
                }
                MethodInfo[] methods = MethodInfoFinder.FindAll(controllerType);
                foreach (MethodInfo method in methods)
                {
                    TFunction action = GetFunction(method);
                    if (action == null)
                    {
                        continue;
                    }
                    if (IsIgnoreMethod(action, method, functions))
                    {
                        continue;
                    }
                    functions.Add(action);
                }
            }
            return(functions.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从控制器类型中获取功能信息集合
        /// </summary>
        /// <param name="types">控制器类型</param>
        /// <returns>功能信息集合</returns>
        protected virtual TFunction[] GetFunctions(Type[] types)
        {
            List <TFunction> functions = new List <TFunction>();

            foreach (Type controllerType in types.OrderBy(m => m.FullName))
            {
                TFunction controller = GetFunction(controllerType);
                if (!ExistsFunction(functions, controller))
                {
                    functions.Add(controller);
                }
                MethodInfo[] methods = MethodInfoFinder.FindAll(controllerType);
                foreach (MethodInfo method in methods)
                {
                    TFunction action      = GetFunction(method);
                    TFunction existAction = GetFunction(functions, action.Action, action.Controller, action.Area, action.Name);
                    //忽略指定条件的已存在的功能信息
                    if (existAction != null && IsIgnoreMethod(method))
                    {
                        continue;
                    }
                    if (existAction == null)
                    {
                        functions.Add(action);
                    }
                }
            }
            return(functions.ToArray());
        }