Ejemplo n.º 1
0
        public void LoadAttribute(string plugfile)
        {
            if (dllList.Count > 0)
            {
                switch (appType)
                {
                case AppType.Web:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WebControllerManager.LoadAttribute(dllList, this);
                    WebServicesManager.LoadAttribute(dllList, cache, plugin.name);
                    break;

                case AppType.Winform:
                    //case AppType.WCFClient:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WinformControllerManager.LoadAttribute(dllList, this);
                    break;

                case AppType.WCF:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WcfControllerManager.LoadAttribute(dllList, this);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadAttribute(string plugfile)
        {
            string          dllpath = new System.IO.FileInfo(plugfile).DirectoryName + "\\dll";
            List <Assembly> dllList = new List <Assembly>();

            foreach (businessinfoDll dll in plugin.businessinfoDllList)
            {
                //方式一:直接读取文件,这种方式不支持热插拔
                dllList.Add(Assembly.LoadFrom(dllpath + "\\" + dll.name));
                //方式二:把dll读到内存再加载,再次加载内存会不断变大
                //FileStream fs = new FileStream(dllpath + "\\" + dll.name, FileMode.Open, FileAccess.Read);
                //BinaryReader br = new BinaryReader(fs);
                //byte[] bFile = br.ReadBytes((int)fs.Length);
                //br.Close();
                //fs.Close();
                //dllList.Add(Assembly.Load(bFile));
            }
            if (dllList.Count > 0)
            {
                switch (appType)
                {
                case AppType.Web:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WebControllerManager.LoadAttribute(dllList, this);
                    WebServicesManager.LoadAttribute(dllList, cache, plugin.name);
                    break;

                case AppType.Winform:
                case AppType.WCFClient:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WinformControllerManager.LoadAttribute(dllList, this);
                    break;

                case AppType.WCF:
                    EntityManager.LoadAttribute(dllList, cache, plugin.name);
                    WcfControllerManager.LoadAttribute(dllList, this);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public static void AddPlugin(string plugfile)
        {
            if (PluginDic == null)
            {
                PluginDic = new Dictionary <string, ModulePlugin>();
            }

            ModulePlugin mp = new ModulePlugin();

            mp.LoadPlugin(plugfile);

            if (PluginDic.ContainsKey(mp.plugin.name) == false)
            {
                PluginDic.Add(mp.plugin.name, mp);
                List <string> dllList = new List <string>();
                switch (AppGlobal.appType)
                {
                case AppType.Web:
                    foreach (businessinfoDll dll in mp.plugin.businessinfoDllList)
                    {
                        dllList.Add(AppGlobal.AppRootPath + "bin\\" + dll.name);
                    }
                    if (dllList.Count > 0)
                    {
                        EntityManager.LoadAttribute(dllList, mp.cache, mp.plugin.name);
                        WebControllerManager.LoadAttribute(dllList, mp);
                        WebServicesManager.LoadAttribute(dllList, mp.cache, mp.plugin.name);
                    }
                    break;

                case AppType.Winform:
                    foreach (businessinfoDll dll in mp.plugin.businessinfoDllList)
                    {
                        dllList.Add(AppGlobal.AppRootPath + dll.name);
                    }
                    if (dllList.Count > 0)
                    {
                        EntityManager.LoadAttribute(dllList, mp.cache, mp.plugin.name);
                        WinformControllerManager.LoadAttribute(dllList, mp);
                    }
                    break;

                case AppType.WCF:
                    foreach (businessinfoDll dll in mp.plugin.businessinfoDllList)
                    {
                        dllList.Add(AppGlobal.AppRootPath + dll.name);
                    }
                    if (dllList.Count > 0)
                    {
                        EntityManager.LoadAttribute(dllList, mp.cache, mp.plugin.name);
                        WcfControllerManager.LoadAttribute(dllList, mp);
                    }
                    break;

                case AppType.WCFClient:
                    foreach (businessinfoDll dll in mp.plugin.businessinfoDllList)
                    {
                        dllList.Add(AppGlobal.AppRootPath + dll.name);
                    }
                    if (dllList.Count > 0)
                    {
                        WinformControllerManager.LoadAttribute(dllList, mp);
                    }
                    break;
                }
            }
        }