/// <summary> /// 通过给定的文件加载控件菜单 /// </summary> /// <param name="appPath"></param> /// <param name="menufile"></param> public void RegisterPlugins(string appPath, params string[] menufile) { //装载插件文件夹下所有插件,注册成插件菜单 this.pluginMenu = PlugInLoadHelper.LoadAllPlugIns(appPath, _startupInterface, menufile); //this.RegisterMenuPlugins(); _log.Info("Menu Reader Over"); }
private bool ValidatePlugin(string assemblyName, string startupClassName, bool notShowMessage, out Type startupType) { startupType = null; Assembly assembly; try { assembly = PlugInLoadHelper.LoadPlugIn(Application.StartupPath, assemblyName); } catch (FileNotFoundException) { if (!notShowMessage) { MessageBox.Show("所给定的程序集不存在"); } return(false); } try { startupType = assembly.GetType(startupClassName, true, true); } catch (TypeLoadException) { if (!notShowMessage) { MessageBox.Show("所给定的启动类[" + startupClassName + "]不存在!"); } return(false); } //检查所给定的启动类是否实现了DrectSoft.Framework.IStartup接口 Type startupInterfaceType = startupType.GetInterface(_startupInterface); if (startupInterfaceType == null) { if (!notShowMessage) { MessageBox.Show("所给定的启动类没有实现[" + _startupInterface + "]接口!"); } return(false); } return(true); }
private static AppDomain GetCustomAppDomain() { PlugInLoadHelper @object = new PlugInLoadHelper(Application.StartupPath); DrectSoftConfigurationSectionHandler.SetConfigurationDelegate(new DelegateReadConfiguration(@object.ReadPlugInLoadConfiguration)); PlugInLoadConfiguration plugInLoadConfiguration = (PlugInLoadConfiguration)ConfigurationManager.GetSection("plugInLoadSettings"); AppDomainSetup appDomainSetup = new AppDomainSetup(); appDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; appDomainSetup.ApplicationName = "DrectSoftEMR"; appDomainSetup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; appDomainSetup.PrivateBinPath = plugInLoadConfiguration.AllPath; if (plugInLoadConfiguration.UseShadowCopy) { appDomainSetup.ShadowCopyFiles = "true"; appDomainSetup.CachePath = plugInLoadConfiguration.CachePath; } return(AppDomain.CreateDomain("DrectSoftEMR", null, appDomainSetup)); }
static AppDomain GetCustomAppDomain() { PlugInLoadHelper plugInLoadHelper = new PlugInLoadHelper(Application.StartupPath); DrectSoftConfigurationSectionHandler.SetConfigurationDelegate(plugInLoadHelper.ReadPlugInLoadConfiguration); PlugInLoadConfiguration plugInLoadConfig = (PlugInLoadConfiguration)ConfigurationManager.GetSection("plugInLoadSettings"); AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; ads.ApplicationName = "adcemr"; ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; ads.PrivateBinPath = plugInLoadConfig.AllPath; if (plugInLoadConfig.UseShadowCopy) { ads.ShadowCopyFiles = "true"; ads.CachePath = plugInLoadConfig.CachePath; } return(AppDomain.CreateDomain("adcemr", null, ads)); }