Exemplo n.º 1
0
        /// <summary>
        /// 加载属性项信息
        /// </summary>
        private void LoadItemCache()
        {
            string directory = ModelPath + "gencache\\";
            string fileName  = directory + _curEntityInfo.FullName + ".cache.xml";

            if (!File.Exists(fileName))
            {
                return;
            }
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(fileName);
            }
            catch { return; }
            XmlNodeList nodes = doc.GetElementsByTagName("modelitem");


            List <UIModelItem> lstCurPropertys = _curEntityInfo.Propertys;
            List <UIModelItem> lstNewPropertys = new List <UIModelItem>(lstCurPropertys.Count);

            for (int j = 0; j < nodes.Count; j++)
            {
                XmlNode      node = nodes[j];
                XmlAttribute att  = node.Attributes["name"];
                if (att == null)
                {
                    continue;
                }
                string name = att.InnerText;
                if (name == null)
                {
                    continue;
                }
                for (int i = lstCurPropertys.Count - 1; i >= 0; i--)
                {
                    UIModelItem item = lstCurPropertys[i];
                    if (item.PropertyName == name)
                    {
                        att = node.Attributes["isgen"];
                        if (att != null)
                        {
                            item.IsGenerate = att.InnerText == "1";
                        }

                        item.ReadItem(node, _configItemInfo);
                        lstNewPropertys.Add(item);
                        lstCurPropertys.RemoveAt(i);
                        break;
                    }
                }
            }
            _curEntityInfo.Propertys = lstNewPropertys;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载属性项信息
        /// </summary>
        private void LoadClassItemCache()
        {
            _classInfo = new UIModelItem();
            _classInfo.InitDefaultValue(_config.ClassItems, CurEntityInfo, CurEntityInfo.DesignerInfo.CurrentProject, null);
            string fileName = ModelPath + "\\classinfo.cache.xml";

            if (!File.Exists(fileName))
            {
                return;
            }
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(fileName);
            }
            catch { return; }
            XmlNodeList nodes = doc.GetElementsByTagName("root");

            if (nodes.Count <= 0)
            {
                return;
            }
            XmlNode nodeRoot = nodes[0];

            XmlAttribute attRoot = nodeRoot.Attributes["model"];

            if (attRoot != null)
            {
                string mname = attRoot.InnerText;
                if (!string.IsNullOrEmpty(mname))
                {
                    foreach (UIProject upro in _config.Projects)
                    {
                        if (upro.Name == mname)
                        {
                            cmbModels.Value = upro;
                            break;
                        }
                    }
                }
            }

            attRoot = nodeRoot.Attributes["project"];
            if (attRoot != null)
            {
                string pname = attRoot.InnerText;
                if (!string.IsNullOrEmpty(pname))
                {
                    foreach (Project ipro in _lstProjects)
                    {
                        if (ipro.Name == pname)
                        {
                            cmbProjects.Value = ipro;
                            break;
                        }
                    }
                }
            }

            _classInfo.ReadItem(nodeRoot, _configClassInfo);
        }