Ejemplo n.º 1
0
        public static void Pokemon(string location = "")
        {
            if (location == "")
            {
                Console.WriteLine("Drag and drop the Pokemon file and press enter...");
                location = Console.ReadLine();
            }
            var pokemonList = Parser.ParsePokemon(location);

            pokemonList.Sort((m1, m2) => m1.NationalNumber.CompareTo(m2.NationalNumber));
            foreach (var pokemon in pokemonList)
            {
                Console.WriteLine(pokemon.Name);
            }

            Console.WriteLine(string.Format("There are {0} Pokemon in this list!", pokemonList.Count));
            Console.WriteLine("Saving to XML");

            var xml  = new System.Xml.Serialization.XmlSerializer(typeof(List <Pokemon>));
            var path = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Files", "pokemon.xml");

            var stream = new System.IO.StreamWriter(path);

            xml.Serialize(stream, pokemonList);
            stream.Flush();
            stream.Close();
            Console.WriteLine("Done");
            Console.WriteLine("Output at {0}", path);
        }