private static string ResolveNamedLocation(Country country, NamedLocation namedLocation, string location) { // If the location is the displayName then don't flip. if (string.Compare(location, namedLocation.Name, StringComparison.InvariantCultureIgnoreCase) == 0) { return(location); } // If the location is just a case variation on the full string representation then don't flip. if (string.Compare(location, namedLocation.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0) { return(location); } // If it is using one of the location synonyms then don't flip. if (_locationQuery.IsLocationSynonym(country, location, namedLocation)) { return(location); } return(namedLocation.ToString()); }
public static string GetRecord(string displayName, NamedLocation namedLocation, bool includeId, bool includeType) { var sb = new StringBuilder(); if (includeId) { sb.Append(namedLocation.Id); } string type; if (namedLocation is CountrySubdivision) { var cs = (CountrySubdivision)namedLocation; if (cs.IsCountry) { type = CountryType; displayName = AnywherePrefix + cs.Country.Name; } else { type = CountrySubdivisionType; if (displayName == null) { displayName = cs.Name; } } } else if (namedLocation is Region) { type = RegionType; } else if (namedLocation is PostalSuburb) { type = PostalSuburbType; } else { throw new ArgumentException("List item of type '" + namedLocation.GetType() + "' is unknown."); } if (includeType) { sb.Append(TypeDivider).Append(type); } if (includeId) { sb.Append(NameDivider); } if (displayName == null) { displayName = namedLocation.ToString(); } sb.Append(displayName); return(sb.ToString()); }