public void SetCensusReferenceDetails(CensusReference cr, CensusLocation cl, string comment) { if (!HasValidCensusReference) { this.CensusReference = cr; } if (Location.IsBlank) { Location = cl.Equals(CensusLocation.UNKNOWN) ? FactLocation.GetLocation(cr.Country, Properties.GeneralSettings.Default.AddCreatedLocations) : FactLocation.GetLocation(cl.Location, Properties.GeneralSettings.Default.AddCreatedLocations); } if (Comment.Length == 0 && comment.Length > 0) { Comment = comment; } }
static CensusLocation() { #region Census Locations // load Census Locations from XML file string startPath; if (Application.StartupPath.Contains("COMMON7\\IDE")) // running unit tests { startPath = Path.Combine(Environment.CurrentDirectory, "..\\..\\.."); } else { startPath = Application.StartupPath; } string filename = Path.Combine(startPath, @"Resources\CensusLocations.xml"); if (File.Exists(filename)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); //xmlDoc.Validate(something); foreach (XmlNode n in xmlDoc.SelectNodes("CensusLocations/Location")) { string year = n.Attributes["Year"].Value; string piece = n.Attributes["Piece"].Value; string RD = n.Attributes["RD"].Value; string parish = n.Attributes["Parish"].Value; string county = n.Attributes["County"].Value; string location = n.InnerText; CensusLocation cl = new CensusLocation(year, piece, RD, parish, county, location); CENSUSLOCATIONS.Add(new Tuple <string, string>(year, piece), cl); } } #endregion #region Test CensusLocation.xml file //foreach(KeyValuePair<Tuple<string, string>, CensusLocation> kvp in CENSUSLOCATIONS) //{ // FactLocation.GetLocation(kvp.Value.Location); // force creation of location facts //} #endregion }