Exemple #1
0
        //载入所有配置节点
        public void LoadConfigs(XmlNode parentNode, List<Config> configs)
        {
            foreach (XmlNode sitem in parentNode.ChildNodes)
            {
                if (!(sitem is XmlElement)) continue;
                var item = sitem as XmlElement;

                Config config = new Config();
                config.Name = item.GetAttribute("name");
                //config.Type = item.GetAttribute("type");
                config.Url = item.GetAttribute("url");
                config.Id = item.GetAttribute("id");

                if (config.Name == "") config.Name = null;
                if (config.Url == "") config.Url = null;

                foreach (XmlNode sonNode in item.ChildNodes)
                {
                    if (sonNode.Name == "Values")
                        LoadValues(sonNode, config.Values);
                    else if (sonNode.Name == "Nodes")
                        LoadNodes(sonNode, config.Nodes);
                }
                configs.Add(config);
            }
        }
Exemple #2
0
        //linq支持有问题,就用这个替代
        public UrlDir.UrlConfig GetUrlConfig(IEnumerable<UrlDir.UrlConfig> AllConfigs, Config config)
        {
            foreach (UrlDir.UrlConfig item in AllConfigs)
            {
                bool ItsYou = false;
                if (config.Url != null && item.url == config.Url)
                    ItsYou = true;
                else if (config.Name != null && item.name == config.Name)
                    ItsYou = true;

                if (ItsYou == true)
                {
                    //如果没有id就直接返回
                    if (config.Id == null || config.Id == "") return item;
                    //如果有ID,那么就多增加ID方面的判断-----//此处逻辑要修改,让他更加灵活
                    foreach (ConfigNode.Value kspValue in item.config.values)
                    {
                        if (kspValue.name == "id" && kspValue.value == config.Id)
                        {
                            return item;
                        }
                    }
                }
            }
            return null;
        }