/// <summary> /// 查找本地默认目录下,已安装的插件.并启动<br></br> /// 寻找PligIns目录下的plugin.conf文件,并执行start方法 /// </summary> public void Start() { try { if (state == PlugInRuntimeState.Started) { throw new Exception("已启动"); } state = PlugInRuntimeState.Starting; //初始化框架---之后所有相关都使用这一个Framework对象 _framework = VSDT.Framework.Inistace; _framework.dte = DTEObject; _framework.Package = Package; _framework.ServiceProvider = ServiceProvider; FrameworkOptions option = new FrameworkOptions(); option.StartUpDir = Common.Utility.UtilityEnvironment.GetFrameworkBinPath(); _framework.Options = option; //初始化插件信息 InitializePlugIns(); //启动自动启动项 Start(StartMode.Autorun); state = PlugInRuntimeState.Started; } catch (Exception ex) { Log.ShowErrorBox(ex); } }
public void Stop() { try { if (state == PlugInRuntimeState.Stopped) { throw new Exception("已启动"); } state = PlugInRuntimeState.Stopping; //停止 for (int i = 0; i < Framework.PlugIns.Count; i++) { PlugIns.IPlugIn plugIn = Framework.PlugIns[i]; if (plugIn.RunTimeState == PlugInRuntimeState.Started) { plugIn.Stop(); } } state = PlugInRuntimeState.Stopped; } catch (Exception ex) { Log.ShowErrorBox(ex); } }
/// <summary> /// 启动 /// </summary> public void Start() { try { if (enableState != PlugInEnableState.Enable) { throw new Exception("插件不可用"); } if (runTimeState == PlugInRuntimeState.Started) { throw new Exception("插件已启动"); } runTimeState = PlugInRuntimeState.Starting; //先读取xml配置 StartFromXML(); //如果定义了入口点,则执行入口点方法 if (PlugInInfo.PlugInData.EntryPoint != null && !string.IsNullOrEmpty(PlugInInfo.PlugInData.EntryPoint.Type)) { //如果定义入口点,则去找start方法 StartFromCode(); } runTimeState = PlugInRuntimeState.Started; } catch (Exception ex) { Log.ShowErrorBox(ex); } }
/// <summary> /// 停止 /// </summary> public void Stop() { try { if (runTimeState != PlugInRuntimeState.Started) { //未启动 throw new Exception("未启动"); } runTimeState = PlugInRuntimeState.Stopping; //先读取xml配置..停止通过xml启动的项 StopFromXML(); //如果定义了入口点,则执行入口点方法 if (PlugInInfo.PlugInData.EntryPoint != null && !string.IsNullOrEmpty(PlugInInfo.PlugInData.EntryPoint.Type)) { //如果定义入口点,则去找stop方法 StopFromCode(); } runTimeState = PlugInRuntimeState.Stopped; } catch (Exception ex) { Log.ShowErrorBox(ex); } }