Esempio n. 1
0
        public static void LoadClass(XmlNodeList xmlNodes, ref List <ClassElementEx> emt)
        {
            ClassElementEx classEmt = new ClassElementEx();

            classEmt.ClassName = xmlNodes.Item(0).ParentNode.LocalName;
            foreach (XmlElement item in xmlNodes)
            {
                var a = item.ParentNode.LocalName;
                //得到最外层模块名
                ClassPropertyElement proEmt = new ClassPropertyElement();
                if (item.HasChildNodes && item.FirstChild.NodeType != XmlNodeType.Text)
                {
                    //类型
                    proEmt.IsCustromClass = true;
                    proEmt.PropertyName   = item.LocalName;
                    proEmt.PropertyValue  = item.HasAttributes ? GetAttributeValue(item) : item.FirstChild != null && item.FirstChild.NodeType == XmlNodeType.Text ? item.InnerText : "";
                    LoadClass(item.ChildNodes, ref emt);
                }
                else if (!item.HasChildNodes || item.FirstChild.NodeType == XmlNodeType.Text)
                {
                    //属性
                    proEmt.IsCustromClass = false;
                    proEmt.PropertyName   = item.LocalName;
                    proEmt.PropertyValue  = item.HasAttributes ? GetAttributeValue(item) : item.FirstChild != null && item.FirstChild.NodeType == XmlNodeType.Text ? item.InnerText : "";
                }
                classEmt.Propertes.Add(proEmt);
            }
            emt.Add(classEmt);
        }
Esempio n. 2
0
        public static List <ClassElementEx> Begin()
        {
            List <ClassElementEx> emtTmp = new List <ClassElementEx>();
            XmlDocument           xml    = new XmlDocument();

            xml.LoadXml(Resource1.Language_Cn);

            ClassElementEx languageElement = new ClassElementEx();

            languageElement.ClassName = "LanguageResource";
            foreach (var item in xml.DocumentElement.ChildNodes)
            {
                if (item is XmlElement)
                {
                    var xmlItem = item as XmlElement;
                    //得到最外层模块名
                    ClassPropertyElement emt = new ClassPropertyElement();
                    if (xmlItem.HasChildNodes && xmlItem.FirstChild.NodeType != XmlNodeType.Text)
                    {
                        //类型
                        emt.IsCustromClass = true;
                        emt.PropertyName   = xmlItem.LocalName;
                        emt.PropertyValue  = xmlItem.HasAttributes ? GetAttributeValue(xmlItem) : xmlItem.FirstChild != null && xmlItem.FirstChild.NodeType == XmlNodeType.Text ? xmlItem.InnerText : "";
                        LoadClass(xmlItem.ChildNodes, ref emtTmp);
                    }
                    else if (!xmlItem.HasChildNodes || xmlItem.FirstChild.NodeType == XmlNodeType.Text)
                    {
                        //属性
                        emt.IsCustromClass = false;
                        emt.PropertyName   = xmlItem.LocalName;
                        emt.PropertyValue  = xmlItem.HasAttributes ? GetAttributeValue(xmlItem) : xmlItem.FirstChild != null && xmlItem.FirstChild.NodeType == XmlNodeType.Text ? xmlItem.InnerText : "";
                    }
                    languageElement.Propertes.Add(emt);
                }
            }
            emtTmp.Add(languageElement);
            return(emtTmp);
        }