Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 主程序发生事件,需要启动相应构件
 /// </summary>
 /// <param name="xmlnamespace">构件所属的命名空间</param>
 /// <returns>本构件加载是否成功true:成功,false失败</returns>
 public static object MainEventProcess(string xmlnamespace)
 {
     try
     {
         PlugDom dom = domcollection[xmlnamespace];
         if (dom == null)
         {
             throw new System.Exception(
                       "在系统当前上下文构件集合中未能查找出" + xmlnamespace + "命名空间构件,请检查构件配置文件LoadConfig.xml是否进行了相应的设置;");
         }
         ComeLoadEvent(dom.Assembly);      //构件初始化成功
         return(ReflectionDomObject(dom)); //通过反射DLL文件,启动实现构件
     }
     catch (Exception err)
     {
         ComeCommonMethod.LogFunction.WritePrivateProfileString(
             "MainEventProcess", err.Source + "->" + err.TargetSite, err.Message, Environment.CurrentDirectory + "\\PlugManagerLog.ini");
         return(null);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 内部方法,根据InitXmlNsDomReferences方法得出所有的命名空间映射关系,将文档对象化为DOM
 /// </summary>
 /// <returns>bool</returns>
 private static bool GetDomObjectByXmlns()
 {
     try
     {
         domcollection = new PlugDomCollection();                                                           //实例化后才能用
         XmlDocument document = new XmlDocument();
         document.Load(Environment.CurrentDirectory + "\\LoadConfig.xml");                                  //加载构件配置文件LoadConfig.xml
         XmlNode DetailsElement = document.DocumentElement.SelectSingleNode("F:ComeDetails", XmlNsManager); //获取R:ComeRoot
         foreach (XmlElement el in DetailsElement.ChildNodes)
         {
             PlugDom dom = new PlugDom(el.NamespaceURI, el.Attributes["Assembly"].Value, el.LocalName);
             domcollection.Add(dom);
         }
         return(true);
     }
     catch (Exception err)
     {
         ComeCommonMethod.LogFunction.WritePrivateProfileString(
             "GetDomObjectByXmlns", err.Source + "->" + err.TargetSite, err.Message, Environment.CurrentDirectory + "\\PlugManagerLog.ini");
         return(false);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 加对象添加到PlugDomCollection的末尾处
 /// </summary>
 /// <param name="dom">PlugDom</param>
 public void Add(PlugDom dom)
 {
     domlist.Add(dom);
 }