Exemplo n.º 1
0
        public bool Parse(XmlNode node)
        {
            if (node.Attributes != null && node.Attributes["upgrade_cost"] != null)
            {
                var s = node.Attributes["upgrade_cost"].Value;
                upgrade_cost = GenericStringParser.GetObjectList <CostItem>(s);
            }
            if (node.Attributes != null && node.Attributes["add_furniture"] != null)
            {
                var s = node.Attributes["add_furniture"].Value;
                add_furniture = GenericStringParser.GetObjectList <ObjectLayout>(s);
            }
            if (node.Attributes != null && node.Attributes["level"] != null)
            {
                level = int.Parse(node.Attributes["level"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("level");
                if (child != null)
                {
                    level = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["size"] != null)
            {
                size = int.Parse(node.Attributes["size"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("size");
                if (child != null)
                {
                    size = int.Parse(child.InnerText);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public List <SceneLevel> SceneLevelList = new List <SceneLevel>(); //默认从下级节点解析

        public bool Parse(XmlNode node)
        {
            {
                var mid_node = node.SelectSingleNode("SceneLevelList");
                if (mid_node == null)
                {
                    mid_node = node;
                }
                var child_node = mid_node.SelectNodes("SceneLevel");
                if (child_node == null)
                {
                    child_node = mid_node.ChildNodes;
                }
                foreach (XmlNode n in child_node)
                {
                    SceneLevel value = new SceneLevel();
                    if (!value.Parse(n))
                    {
                        return(false);
                    }
                    SceneLevelList.Add(value);
                }
            }
            if (node.Attributes != null && node.Attributes["def_layout"] != null)
            {
                var s = node.Attributes["def_layout"].Value;
                def_layout = GenericStringParser.GetObjectList <ObjectLayout>(s);
            }
            if (node.Attributes != null && node.Attributes["open_cost"] != null)
            {
                var s = node.Attributes["open_cost"].Value;
                open_cost = GenericStringParser.GetObjectList <CostItem>(s);
            }
            if (node.Attributes != null && node.Attributes["name"] != null)
            {
                name = node.Attributes["name"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("name");
                if (child != null)
                {
                    name = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["type"] != null)
            {
                type = (HomeType)int.Parse(node.Attributes["type"].Value);
            }
            if (node.Attributes != null && node.Attributes["id"] != null)
            {
                id = int.Parse(node.Attributes["id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("id");
                if (child != null)
                {
                    id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["open_level"] != null)
            {
                open_level = int.Parse(node.Attributes["open_level"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("open_level");
                if (child != null)
                {
                    open_level = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["def_ground"] != null)
            {
                def_ground = int.Parse(node.Attributes["def_ground"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("def_ground");
                if (child != null)
                {
                    def_ground = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["def_terrain"] != null)
            {
                def_terrain = int.Parse(node.Attributes["def_terrain"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("def_terrain");
                if (child != null)
                {
                    def_terrain = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["def_bg"] != null)
            {
                def_bg = int.Parse(node.Attributes["def_bg"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("def_bg");
                if (child != null)
                {
                    def_bg = int.Parse(child.InnerText);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool Parse(XmlNode node)
        {
            if (node.Attributes != null && node.Attributes["recover_time_reduce_map"] != null)
            {
                var s = node.Attributes["recover_time_reduce_map"].Value;
                recover_time_reduce_map = GenericStringParser.GetObjectList <ReduceMap>(s);
            }
            if (node.Attributes != null && node.Attributes["health_phase_img"] != null)
            {
                health_phase_img = node.Attributes["health_phase_img"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("health_phase_img");
                if (child != null)
                {
                    health_phase_img = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["normal_phase_img"] != null)
            {
                normal_phase_img = node.Attributes["normal_phase_img"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("normal_phase_img");
                if (child != null)
                {
                    normal_phase_img = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["tired_phase_img"] != null)
            {
                tired_phase_img = node.Attributes["tired_phase_img"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("tired_phase_img");
                if (child != null)
                {
                    tired_phase_img = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["out_heart_time"] != null)
            {
                out_heart_time = int.Parse(node.Attributes["out_heart_time"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("out_heart_time");
                if (child != null)
                {
                    out_heart_time = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["storage_max_count"] != null)
            {
                storage_max_count = int.Parse(node.Attributes["storage_max_count"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("storage_max_count");
                if (child != null)
                {
                    storage_max_count = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["recover_health_time"] != null)
            {
                recover_health_time = int.Parse(node.Attributes["recover_health_time"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("recover_health_time");
                if (child != null)
                {
                    recover_health_time = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["health_out_rate"] != null)
            {
                health_out_rate = int.Parse(node.Attributes["health_out_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("health_out_rate");
                if (child != null)
                {
                    health_out_rate = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["normal_out_rate"] != null)
            {
                normal_out_rate = int.Parse(node.Attributes["normal_out_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("normal_out_rate");
                if (child != null)
                {
                    normal_out_rate = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["tired_out_rate"] != null)
            {
                tired_out_rate = int.Parse(node.Attributes["tired_out_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("tired_out_rate");
                if (child != null)
                {
                    tired_out_rate = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["recover_heart_time"] != null)
            {
                recover_heart_time = int.Parse(node.Attributes["recover_heart_time"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("recover_heart_time");
                if (child != null)
                {
                    recover_heart_time = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["min_work_time"] != null)
            {
                min_work_time = int.Parse(node.Attributes["min_work_time"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("min_work_time");
                if (child != null)
                {
                    min_work_time = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["max_work_time"] != null)
            {
                max_work_time = int.Parse(node.Attributes["max_work_time"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("max_work_time");
                if (child != null)
                {
                    max_work_time = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["health_phase_rate"] != null)
            {
                health_phase_rate = int.Parse(node.Attributes["health_phase_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("health_phase_rate");
                if (child != null)
                {
                    health_phase_rate = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["normal_phase_rate"] != null)
            {
                normal_phase_rate = int.Parse(node.Attributes["normal_phase_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("normal_phase_rate");
                if (child != null)
                {
                    normal_phase_rate = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["tired_phase_rate"] != null)
            {
                tired_phase_rate = int.Parse(node.Attributes["tired_phase_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("tired_phase_rate");
                if (child != null)
                {
                    tired_phase_rate = int.Parse(child.InnerText);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
 public void TimeSpan_Try_Parser()
 {
     var g = new GenericStringParser<TimeSpan>();
     TimeSpan tm;
     Assert.False(g.TryParse("2#12:00",out tm));
 }
Exemplo n.º 5
0
        public bool Parse(XmlNode node)
        {
            {
                var mid_node = node.SelectSingleNode("FurnitureList");
                if (mid_node == null)
                {
                    mid_node = node;
                }
                var child_node = mid_node.SelectNodes("Furniture");
                if (child_node == null)
                {
                    child_node = mid_node.ChildNodes;
                }
                foreach (XmlNode n in child_node)
                {
                    Furniture value = new Furniture();
                    if (!value.Parse(n))
                    {
                        return(false);
                    }
                    FurnitureList.Add(value);
                }
            }
            if (node.Attributes != null && node.Attributes["outreward"] != null)
            {
                var s = node.Attributes["outreward"].Value;
                outreward = GenericStringParser.GetObject <Reward>(s);
            }
            if (node.Attributes != null && node.Attributes["name"] != null)
            {
                name = node.Attributes["name"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("name");
                if (child != null)
                {
                    name = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["anim_id"] != null)
            {
                anim_id = node.Attributes["anim_id"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("anim_id");
                if (child != null)
                {
                    anim_id = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["id"] != null)
            {
                id = int.Parse(node.Attributes["id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("id");
                if (child != null)
                {
                    id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["out_action_rate"] != null)
            {
                out_action_rate = float.Parse(node.Attributes["out_action_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("out_action_rate");
                if (child != null)
                {
                    out_action_rate = float.Parse(child.InnerText);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        public bool Parse(XmlNode node)
        {
            if (node.Attributes != null && node.Attributes["cost"] != null)
            {
                var s = node.Attributes["cost"].Value;
                cost = GenericStringParser.GetObjectList <CostItem>(s);
            }
            if (node.Attributes != null && node.Attributes["level"] != null)
            {
                level = int.Parse(node.Attributes["level"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("level");
                if (child != null)
                {
                    level = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["player_level"] != null)
            {
                player_level = int.Parse(node.Attributes["player_level"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("player_level");
                if (child != null)
                {
                    player_level = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["pos_count"] != null)
            {
                pos_count = int.Parse(node.Attributes["pos_count"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("pos_count");
                if (child != null)
                {
                    pos_count = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["out_interval"] != null)
            {
                out_interval = int.Parse(node.Attributes["out_interval"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("out_interval");
                if (child != null)
                {
                    out_interval = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["out_level_rate"] != null)
            {
                out_level_rate = float.Parse(node.Attributes["out_level_rate"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("out_level_rate");
                if (child != null)
                {
                    out_level_rate = float.Parse(child.InnerText);
                }
            }

            return(true);
        }
 public void PassingNullMethodToTryParseDefaultThrows()
 {
     Assert.Throws <ArgumentNullException>(() => GenericStringParser.TryParseDefault(null, 0, null));
 }
 public T Parse(T defaultValue = default(T))
 {
     return(GenericStringParser.TryParseDefault(_input, defaultValue, _tryParseMethod));
 }
 public void PassingNullMethodToParseCultureThrows()
 {
     Assert.Throws <ArgumentNullException>(() => GenericStringParser.ParseCulture <int>(null, null, null));
 }
 public void PassingNullMethodToTryParseNullableThrows()
 {
     Assert.Throws <ArgumentNullException>(() => GenericStringParser.TryParseNullable <int>(null, null));
 }
        public void PassingInvalidValuesToTryParseNullableReturnsNull()
        {
            var result = GenericStringParser.TryParseNullable <int>("ABC", int.TryParse);

            result.Should().Be(null);
        }
        public void PassingValidValuesToTryParseNullablePasses()
        {
            var result = GenericStringParser.TryParseNullable <int>("10", int.TryParse);

            result.Should().Be(10);
        }
        public void PassingValidValuesToParseCulturePasses()
        {
            var result = GenericStringParser.ParseCulture("10", CultureInfo.InvariantCulture, int.Parse);

            result.Should().Be(10);
        }
        public void PassingValidValuesToParsePasses()
        {
            var result = GenericStringParser.Parse("10", int.Parse);

            result.Should().Be(10);
        }
Exemplo n.º 15
0
        public bool Parse(XmlNode node)
        {
            {
                var mid_node = node.SelectSingleNode("pre_sectionId");
                if (mid_node == null)
                {
                    mid_node = node;
                }
                var child_node = mid_node.ChildNodes;
                if (child_node != null)
                {
                    foreach (XmlNode n in child_node)
                    {
                        pre_sectionId.Add(int.Parse(n.InnerText));
                    }
                }
            }
            if (node.Attributes != null && node.Attributes["position"] != null)
            {
                var s = node.Attributes["position"].Value;
                position = GenericStringParser.GetObject <Pos>(s);
            }
            if (node.Attributes != null && node.Attributes["name"] != null)
            {
                name = node.Attributes["name"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("name");
                if (child != null)
                {
                    name = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["describe"] != null)
            {
                describe = node.Attributes["describe"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("describe");
                if (child != null)
                {
                    describe = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["force_main"] != null)
            {
                force_main = node.Attributes["force_main"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("force_main");
                if (child != null)
                {
                    force_main = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["invisible1"] != null)
            {
                invisible1 = node.Attributes["invisible1"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("invisible1");
                if (child != null)
                {
                    invisible1 = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["invisible2"] != null)
            {
                invisible2 = node.Attributes["invisible2"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("invisible2");
                if (child != null)
                {
                    invisible2 = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["buff"] != null)
            {
                buff = node.Attributes["buff"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("buff");
                if (child != null)
                {
                    buff = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["normal_rewards"] != null)
            {
                normal_rewards = node.Attributes["normal_rewards"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("normal_rewards");
                if (child != null)
                {
                    normal_rewards = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["first_rewards"] != null)
            {
                first_rewards = node.Attributes["first_rewards"].Value;
            }
            else
            {
                var child = node.SelectSingleNode("first_rewards");
                if (child != null)
                {
                    first_rewards = child.InnerText;
                }
            }
            if (node.Attributes != null && node.Attributes["id"] != null)
            {
                id = int.Parse(node.Attributes["id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("id");
                if (child != null)
                {
                    id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["chapterId"] != null)
            {
                chapterId = int.Parse(node.Attributes["chapterId"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("chapterId");
                if (child != null)
                {
                    chapterId = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["sceneId"] != null)
            {
                sceneId = int.Parse(node.Attributes["sceneId"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("sceneId");
                if (child != null)
                {
                    sceneId = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["default_env_id"] != null)
            {
                default_env_id = int.Parse(node.Attributes["default_env_id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("default_env_id");
                if (child != null)
                {
                    default_env_id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["section_type"] != null)
            {
                section_type = int.Parse(node.Attributes["section_type"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("section_type");
                if (child != null)
                {
                    section_type = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["unlocklevel"] != null)
            {
                unlocklevel = int.Parse(node.Attributes["unlocklevel"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("unlocklevel");
                if (child != null)
                {
                    unlocklevel = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["difficulty"] != null)
            {
                difficulty = int.Parse(node.Attributes["difficulty"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("difficulty");
                if (child != null)
                {
                    difficulty = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["music_id"] != null)
            {
                music_id = int.Parse(node.Attributes["music_id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("music_id");
                if (child != null)
                {
                    music_id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["plot_id"] != null)
            {
                plot_id = int.Parse(node.Attributes["plot_id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("plot_id");
                if (child != null)
                {
                    plot_id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["pre_plot_id"] != null)
            {
                pre_plot_id = int.Parse(node.Attributes["pre_plot_id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("pre_plot_id");
                if (child != null)
                {
                    pre_plot_id = int.Parse(child.InnerText);
                }
            }
            if (node.Attributes != null && node.Attributes["latter_plot_id"] != null)
            {
                latter_plot_id = int.Parse(node.Attributes["latter_plot_id"].Value);
            }
            else
            {
                var child = node.SelectSingleNode("latter_plot_id");
                if (child != null)
                {
                    latter_plot_id = int.Parse(child.InnerText);
                }
            }

            return(true);
        }