/// <summary> /// Converts a country (full english name, 2 letter or 3 letter) to a 2 or 3 letter ISO abbreiviation. /// </summary> /// <param name="country"> /// The country value /// </param> /// <param name="length"> /// CountryAbbreviationLength length. /// </param> /// <returns> /// The to short. /// </returns> public static string ToShort(string country, CountryAbbreviationLength length) { const string LogCatagory = "Convert > Country > ToShort"; try { CultureInfo name = FindCultureInfo(country); if (name == null) { return(string.Empty); } if (length == CountryAbbreviationLength.TwoLetter) { return(name.ThreeLetterISOLanguageName.ToLower(CultureInfo.CurrentCulture)); } if (length == CountryAbbreviationLength.ThreeLetter) { return(name.TwoLetterISOLanguageName.ToLower(CultureInfo.CurrentCulture)); } } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, LoggerName.GeneralLog, LogCatagory, ex.Message); } return(string.Empty); }
/// <summary> /// Converts a country (full english name, 2 letter or 3 letter) to a 2 or 3 letter ISO abbreiviation. /// </summary> /// <param name="country"> /// The country value /// </param> /// <param name="length"> /// CountryAbbreviationLength length. /// </param> /// <returns> /// The to short. /// </returns> public static string ToShort(string country, CountryAbbreviationLength length) { const string LogCatagory = "Convert > Country > ToShort"; try { CultureInfo name = FindCultureInfo(country); if (name == null) { return string.Empty; } if (length == CountryAbbreviationLength.TwoLetter) { return name.ThreeLetterISOLanguageName.ToLower(CultureInfo.CurrentCulture); } if (length == CountryAbbreviationLength.ThreeLetter) { return name.TwoLetterISOLanguageName.ToLower(CultureInfo.CurrentCulture); } } catch (Exception ex) { Log.WriteToLog(LogSeverity.Error, LoggerName.GeneralLog, LogCatagory, ex.Message); } return string.Empty; }