/// <summary> /// 内部方法,根据Assembly构件宿主程序集名称动态加载内部构件对象 /// </summary> /// <param name="dom">构件文档对象模型PlugDom</param> private static object ReflectionDomObject(PlugDom dom) { try { Assembly ass = Assembly.LoadFile(Path.Combine(_comeloadpath, dom.Assembly)); Type[] entrytype = ass.GetTypes(); foreach (Type type in entrytype) { //所有构件基类,查找构件的入口点 if (type.GetInterface(string.Format("Main.Interface.{0}", dom.Interface)) != null) { Main.Interface.ComeBaseModule.BaseCome basecome = System.Activator.CreateInstance(type, type.FullName, _comeloadpath, DateTime.Now) as Main.Interface.ComeBaseModule.BaseCome; //注册事件 NoteComeLifecycleProcess(basecome); return(basecome); } } throw new Exception("为能实现" + dom.XmlNameSpace + "标识构件,请检查构件配置文件"); } catch (Exception err) { ComeCommonMethod.LogFunction.WritePrivateProfileString( "GetDomObjectByXmlns", err.Source + "->" + err.TargetSite, err.Message, Environment.CurrentDirectory + "\\PlugManagerLog.ini"); return(null); } }
/// <summary> /// 记录所有构件共有的生命周期事件数据 /// </summary> private static void NoteComeLifecycleProcess(Main.Interface.ComeBaseModule.BaseCome basecome) { basecome.ComeStartGoodsEvent += basecome_ComeStartGoodsEvent; basecome.ComeExitGoodsEvent += basecome_ComeExitGoodsEvent; basecome.ComeExceptionEvent += basecome_ComeExceptionEvent; }