예제 #1
0
        private void InitControllers(List <Assembly> actionAssemblyList)
        {
            List <ControllerDescription> serviceControllerList = new List <ControllerDescription>(1024);
            List <ControllerDescription> pageControllerList    = new List <ControllerDescription>(1024);

            ControllerRecognizer recognizer = ObjectFactory.New <ControllerRecognizer>();

            foreach (Assembly assembly in actionAssemblyList)
            {
                foreach (Type t in assembly.GetPublicTypes())
                {
                    if (t.IsClass == false || (t.IsAbstract && t.IsSealed == false) /* 抽象类不能实例化 */)
                    {
                        continue;
                    }

                    if (recognizer.IsPageController(t))
                    {
                        pageControllerList.Add(new ControllerDescription(t));
                    }

                    else if (recognizer.IsServiceController(t))
                    {
                        serviceControllerList.Add(new ControllerDescription(t));
                    }
                }
            }


            BuildServiceActionDict(serviceControllerList);

            BuildPageActionDict(pageControllerList);
        }
예제 #2
0
        private void InitControllers(List <Assembly> actionAssemblyList)
        {
            List <ControllerDescription> serviceControllerList = new List <ControllerDescription>(1024);
            List <ControllerDescription> pageControllerList    = new List <ControllerDescription>(1024);

            ControllerRecognizer recognizer = ObjectFactory.New <ControllerRecognizer>();

            foreach (Assembly assembly in actionAssemblyList)
            {
                foreach (Type t in assembly.GetPublicTypes())
                {
                    //if( t.IsClass == false || (t.IsAbstract && t.IsSealed ==false ) /* 抽象类不能实例化 */ )
                    //	continue;

                    // ERP中有些URL是映射到接口类型上的,所以和上面被注释有冲突
                    // 之前是为了避免出现:根据URL映射到的类型不能实例化,
                    // 现在(2017-06-16)取消这个判断,
                    // 如果真要将URL映射到接口类型或者抽象类,就自行保证是可以实例化,否则将会出现异常
                    // 如果要调整默认的实例化过程,可以重新实现 IControllerResolver 接口,然后调用 ControllerFactory.SetResolver

                    if (recognizer.IsPageController(t))
                    {
                        pageControllerList.Add(new ControllerDescription(t));
                    }

                    else if (recognizer.IsServiceController(t))
                    {
                        serviceControllerList.Add(new ControllerDescription(t));
                    }
                }
            }


            BuildServiceActionDict(serviceControllerList);

            BuildPageActionDict(pageControllerList);
        }