private void ProcessXMLSection(Section section) { if (section == Section.Events) { //Calculate Historical Figure Ages. int lastYear = World.Events.Last().Year; foreach (HistoricalFigure hf in World.HistoricalFigures) { if (hf.DeathYear > 0) { hf.Age = hf.DeathYear - hf.BirthYear; } else { hf.Age = lastYear - hf.BirthYear; } } } if (section == Section.EventCollections) { ProcessCollections(); } //Create sorted Historical Figures so they can be binary searched by name, needed for parsing History file if (section == Section.HistoricalFigures) { World.HistoricalFiguresByName = new List <HistoricalFigure>(World.HistoricalFigures); World.HistoricalFiguresByName.Sort((a, b) => String.Compare(a.Name, b.Name)); World.ProcessHFtoHFLinks(); World.ProcessHFCurrentIdentities(); World.ProcessHFUsedIdentities(); } //Create sorted entities so they can be binary searched by name, needed for History/sites files if (section == Section.Entities) { World.EntitiesByName = new List <Entity>(World.Entities); World.EntitiesByName.Sort((a, b) => String.Compare(a.Name, b.Name)); World.ProcessReputations(); World.ProcessHFtoSiteLinks(); World.ProcessEntityEntityLinks(); } //Calculate end years for eras and add list of wars during era. if (section == Section.Eras) { World.Eras.Last().EndYear = World.Events.Last().Year; for (int i = 0; i < World.Eras.Count - 1; i++) { World.Eras[i].EndYear = World.Eras[i + 1].StartYear - 1; } foreach (Era era in World.Eras) { era.Events = World.Events.Where(events => events.Year >= era.StartYear && events.Year <= era.EndYear).OrderBy(events => events.Year).ToList(); era.Wars = World.EventCollections.OfType <War>().Where(war => (war.StartYear >= era.StartYear && war.EndYear <= era.EndYear && war.EndYear != -1) || //entire war between (war.StartYear >= era.StartYear && war.StartYear <= era.EndYear) || //war started before & ended (war.EndYear >= era.StartYear && war.EndYear <= era.EndYear && war.EndYear != -1) || //war started during (war.StartYear <= era.StartYear && war.EndYear >= era.EndYear) || //war started before & ended after (war.StartYear <= era.StartYear && war.EndYear == -1)).ToList(); } } }