示例#1
0
        public static void LoadAttribute(List <Assembly> BusinessDll, ModulePlugin mp)
        {
            List <WcfControllerAttributeInfo> cmdControllerList = new List <WcfControllerAttributeInfo>();

            for (int k = 0; k < BusinessDll.Count; k++)
            {
                //System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(BusinessDll[k]);
                System.Reflection.Assembly assembly = BusinessDll[k];
                Type[] types = assembly.GetTypes();
                for (int i = 0; i < types.Length; i++)
                {
                    WCFControllerAttribute[] webC = ((WCFControllerAttribute[])types[i].GetCustomAttributes(typeof(WCFControllerAttribute), true));

                    if (webC.Length > 0)
                    {
                        WcfControllerAttributeInfo cmdC = new WcfControllerAttributeInfo();
                        cmdC.controllerName = types[i].Name;
                        //cmdC.wcfController = (AbstractController)Activator.CreateInstance(types[i], null);
                        //cmdC.wcfController = (AbstractController)FactoryModel.GetObject(types[i], mp.database, mp.container, mp.cache, mp.plugin.name, null);
                        cmdC.wcfControllerType = types[i];
                        cmdC.MethodList        = new List <WcfMethodAttributeInfo>();

                        MethodInfo[] property = types[i].GetMethods();
                        for (int n = 0; n < property.Length; n++)
                        {
                            WCFMethodAttribute[] WcfM = (WCFMethodAttribute[])property[n].GetCustomAttributes(typeof(WCFMethodAttribute), true);
                            if (WcfM.Length > 0)
                            {
                                WcfMethodAttributeInfo cmdM = new WcfMethodAttributeInfo();
                                cmdM.methodName = property[n].Name;
                                cmdM.methodInfo = property[n];
                                if (WcfM[0].OpenDBKeys != null && WcfM[0].OpenDBKeys.ToString().Trim() != "")
                                {
                                    cmdM.dbkeys = WcfM[0].OpenDBKeys.Split(new char[] { ',' }).ToList();
                                }
                                cmdM.IsAuthentication = WcfM[0].IsAuthentication;
                                cmdC.MethodList.Add(cmdM);
                            }
                        }

                        cmdControllerList.Add(cmdC);
                    }
                }
            }

            mp.cache.Add(mp.plugin.name + "@" + GetCacheKey(), cmdControllerList);
        }
        public static void LoadAttribute(List<string> BusinessDll, ModulePlugin mp)
        {
            List<WcfControllerAttributeInfo> cmdControllerList = new List<WcfControllerAttributeInfo>();

            for (int k = 0; k < BusinessDll.Count; k++)
            {
                System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(BusinessDll[k]);
                Type[] types = assembly.GetTypes();
                for (int i = 0; i < types.Length; i++)
                {
                    WCFControllerAttribute[] webC = ((WCFControllerAttribute[])types[i].GetCustomAttributes(typeof(WCFControllerAttribute), true));

                    if (webC.Length > 0)
                    {
                        WcfControllerAttributeInfo cmdC = new WcfControllerAttributeInfo();
                        cmdC.controllerName = types[i].Name;
                        //cmdC.wcfController = (AbstractController)Activator.CreateInstance(types[i], null);
                        //cmdC.wcfController = (AbstractController)FactoryModel.GetObject(types[i], mp.database, mp.container, mp.cache, mp.plugin.name, null);
                        cmdC.wcfControllerType = types[i];
                        cmdC.MethodList = new List<WcfMethodAttributeInfo>();

                        MethodInfo[] property = types[i].GetMethods();
                        for (int n = 0; n < property.Length; n++)
                        {
                            WCFMethodAttribute[] WcfM = (WCFMethodAttribute[])property[n].GetCustomAttributes(typeof(WCFMethodAttribute), true);
                            if (WcfM.Length > 0)
                            {
                                WcfMethodAttributeInfo cmdM = new WcfMethodAttributeInfo();
                                cmdM.methodName = property[n].Name;
                                cmdM.methodInfo = property[n];
                                if (WcfM[0].OpenDBKeys != null && WcfM[0].OpenDBKeys.ToString().Trim() != "")
                                    cmdM.dbkeys = WcfM[0].OpenDBKeys.Split(new char[] { ',' }).ToList();
                                cmdC.MethodList.Add(cmdM);
                            }
                        }

                        cmdControllerList.Add(cmdC);
                    }
                }
            }

            mp.cache.Add(mp.plugin.name+"@"+GetCacheKey(), cmdControllerList);
        }