public void Load(string path) { DoAutosave = false; Path = path; using (Stream SettingsStream = File.OpenRead(path)) { XPathDocument Doc = new XPathDocument(SettingsStream); XPathNavigator Reader = Doc.CreateNavigator(); Reader.MoveToRoot(); Reader.MoveToChild("Population", ""); ReadFromXML(Reader); List <Species> AllSpecies = new List <Species>(); foreach (XPathNavigator nav in Reader.Select("Species/Species")) { Guid SpeciesGUID = Guid.Parse(nav.GetAttribute("GUID", "")); string SpeciesPath = nav.GetAttribute("Path", ""); Species LoadedSpecies = Sociology.Species.FromFile(SpeciesPath); if (LoadedSpecies.GUID != SpeciesGUID) { throw new Exception("Stored GUID does not match that of the species."); } AllSpecies.Add(LoadedSpecies); } foreach (var species in AllSpecies) { species.ResolveChildren(AllSpecies); } Species.Clear(); foreach (var toplevel in AllSpecies.Where(s => s.Parent == null)) { Species.Add(toplevel); } foreach (XPathNavigator nav in Reader.Select("Sources/Source")) { string Path = nav.GetAttribute("Path", ""); Guid SourceGUID = Guid.Parse(nav.GetAttribute("GUID", "")); DataSource LoadedSource = DataSource.FromFile(Path); if (SourceGUID != LoadedSource.GUID) { throw new Exception("Stored GUID does not match that of the data source."); } Sources.Add(LoadedSource); } XPathNavigator NavLastRefinementOptions = Reader.SelectSingleNode("//LastRefinementOptions"); if (NavLastRefinementOptions != null) { ProcessingOptionsMPARefine Temp = new ProcessingOptionsMPARefine(); Temp.ReadFromXML(NavLastRefinementOptions); LastRefinementOptions = Temp; } } DoAutosave = true; }