コード例 #1
0
        /// <summary>
        /// 加载模块信息
        /// </summary>
        private static void LoadModel()
        {
            List <Assembly> lstAss = GetAllAssembly();
            Dictionary <string, EntityConfigInfo> dicAllEntityInfo = new Dictionary <string, EntityConfigInfo>();//实体信息

            foreach (Assembly ass in lstAss)
            {
                string[] resourceNames = ass.GetManifestResourceNames();
                foreach (string name in resourceNames)
                {
                    if (name.EndsWith(".BEM.xml", StringComparison.CurrentCultureIgnoreCase))
                    {
                        try
                        {
                            Stream      stm = ass.GetManifestResourceStream(name);
                            XmlDocument doc = new XmlDocument();
                            doc.Load(stm);

                            //获取类名
                            XmlNodeList lstNode = doc.GetElementsByTagName("class");
                            if (lstNode.Count > 0)
                            {
                                XmlNode      classNode = lstNode[0];
                                XmlAttribute att       = classNode.Attributes["ClassName"];
                                if (att != null)
                                {
                                    string className = att.InnerText;
                                    if (!string.IsNullOrEmpty(className))
                                    {
                                        Type cType = ass.GetType(className);

                                        EntityConfigInfo info = new EntityConfigInfo();
                                        info.Type      = cType;
                                        info.ConfigXML = doc;
                                        dicAllEntityInfo[className] = info;
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                    else if (name.EndsWith(".BDM.xml", StringComparison.CurrentCultureIgnoreCase))
                    {
                        Stream      stm = ass.GetManifestResourceStream(name);
                        XmlDocument doc = new XmlDocument();
                        doc.Load(stm);
                        AppendDalLoader(ass, doc);
                        AppendBoLoader(ass, doc);
                    }
                }
            }
            EntityInfoManager.InitAllEntity(dicAllEntityInfo);
        }