public List<Comm.Dto.ControllerInfoListDto> GetControllerInfoFromAssembly(Assembly assembly)
 {
     List<Comm.Dto.ControllerInfoListDto> controllerList = new List<Comm.Dto.ControllerInfoListDto>();
     var currentControllerList = assembly.GetTypes().Where(e => e.FullName.EndsWith("Controller"));
     Comm.Dto.ControllerInfoListDto temp = null;
     foreach (var controller in currentControllerList)
     {
         temp = new Comm.Dto.ControllerInfoListDto();
         temp.ActionNameList = new List<string>();
         foreach (var method in controller.GetMethods())
         {
             //结尾是Result 并且是Public
             if (IsMvcActionResult(method.ReturnType) && method.IsPublic)
             {
                 if (!temp.ActionNameList.Contains(method.Name))
                 {
                     temp.ContorllerType = controller;
                     temp.ActionNameList.Add(method.Name);
                 }
             }
         }
         controllerList.Add(temp);
     }
     return controllerList;
 }
Beispiel #2
0
        public List <Comm.Dto.ControllerInfoListDto> GetControllerInfoFromAssembly(Assembly assembly)
        {
            List <Comm.Dto.ControllerInfoListDto> controllerList = new List <Comm.Dto.ControllerInfoListDto>();
            var currentControllerList = assembly.GetTypes().Where(e => e.FullName.EndsWith("Controller"));

            Comm.Dto.ControllerInfoListDto temp = null;
            foreach (var controller in currentControllerList)
            {
                temp = new Comm.Dto.ControllerInfoListDto();
                temp.ActionNameList = new List <string>();
                foreach (var method in controller.GetMethods())
                {
                    //结尾是Result 并且是Public
                    if (IsMvcActionResult(method.ReturnType) && method.IsPublic)
                    {
                        if (!temp.ActionNameList.Contains(method.Name))
                        {
                            temp.ContorllerType = controller;
                            temp.ActionNameList.Add(method.Name);
                        }
                    }
                }
                controllerList.Add(temp);
            }
            return(controllerList);
        }