示例#1
0
        /// <summary>
        /// Retrieves a Country object using the provided country code
        /// </summary>
        /// <param name="countryCode">Country code representing the country</param>
        /// <returns>A Country object</returns>
        public Country CreateCountry(string countryCode)
        {
            var            normalizedCountryCode = _countryCodeValidator.GetNormalizedCountryCode(countryCode);
            Iso3166Country iso3166Country;

            if (Iso3166Countries.Countries.TryGetValue(normalizedCountryCode, out iso3166Country) == false)
            {
                throw new ArgumentException(string.Format("Unsupported country code: {0}", countryCode));
            }
            if (iso3166Country.Status != Iso3166CountryCodeStatus.OfficiallyAssigned && iso3166Country.Status != Iso3166CountryCodeStatus.TransitionallyReserved)
            {
                throw new ArgumentException(string.Format("Country: {0}, is in status {1}", countryCode, iso3166Country.Status));
            }
            var countryName = iso3166Country.CountryName;

            return(Countries.GetOrAdd(normalizedCountryCode, key => new Country(normalizedCountryCode, countryName)));
        }
示例#2
0
        /// <summary>
        /// Retrieves a Country object using the provided country code and normalizer
        /// </summary>
        /// <param name="countryCode">Country code representing the country</param>
        /// <returns>A Country object</returns>
        public Country CreateCountry(string countryCode)
        {
            var normalizedCountryCode = _countryCodeValidator.GetNormalizedCountryCode(countryCode);

            return(Countries.GetOrAdd(normalizedCountryCode, key => new Country(normalizedCountryCode)));
        }
示例#3
0
 public void GetNormalizedCountryCode_ReturnsValidCountryCode(string input, string output)
 {
     Assert.AreEqual(output, IsoValidator.GetNormalizedCountryCode(input));
 }