using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Xml.Serialization; using TransportGame.Model; using TransportGame.Utils; namespace TransportGame.Business { public static class BiomeManager { private static Dictionary biomes = new Dictionary(); /// /// Gets all the loaded biomes /// public static IEnumerable Biomes { get { return biomes.Values; } } /// /// Loads the biomes from the Biome directory. /// public static void LoadBiomes() { foreach (var file in Directory.GetFiles(ConfigurationManager.BiomeDirectory, "*.xml", SearchOption.AllDirectories)) { try { // Open file var stream = File.OpenRead(file); // Try to deserialize biome XmlSerializer serializer = new XmlSerializer(typeof(Biome)); var biome = (Biome)serializer.Deserialize(stream); // Add it to biome list biomes.Add(file, biome); Logger.Info("Loaded biome '{0}' from file '{1}'.", biome.Name, file); } catch (Exception ex) { Logger.Exception(ex); } } } } }