Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj is CountryCodeEntry)
            {
                CountryCodeEntry other = obj as CountryCodeEntry;
                return(Alpha2.Equals(other.Alpha2) & Alpha3.Equals(other.Alpha3) & CountryName.Equals(other.CountryName));
            }

            return(false);
        }
Ejemplo n.º 2
0
        private CountryCodeEntry getByAlpha2(string code)
        {
            CountryCodeEntry result = null;

            if (_alpha3Map != null)
            {
                if (_alpha3Map.ContainsKey(code))
                {
                    result = _alpha3Map[code];
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets CountryCode object from map
        /// </summary>
        /// <param name="code">2 or 3 letters code for country</param>
        /// <returns>Found CountryCodeItem object or null if it is not found</returns>
        public static CountryCodeEntry GetCountryCode(string code)
        {
            CountryCodeEntry result = null;
            CountryCode      cc     = new CountryCode();

            if (!string.IsNullOrEmpty(code))
            {
                switch (code.Length)
                {
                case 2:
                    result = cc.getByAlpha2(code.ToUpper());
                    break;

                case 3:
                    result = cc.getByAlpha3(code.ToUpper());
                    break;
                }
            }

            return(result);
        }