/// <summary> /// Returns an instance of <see cref="LocaleDisplayNames"/> that returns names formatted for the provided <paramref name="locale"/>, /// using the provided <see cref="DisplayContext"/> settings. /// </summary> /// <param name="locale">The display locale.</param> /// <param name="contexts">One or more context settings (e.g. for dialect handling, capitalization, etc.)</param> /// <returns>A <see cref="LocaleDisplayNames"/> instance.</returns> /// <stable>ICU 51</stable> public static LocaleDisplayNames GetInstance(ULocale locale, params DisplayContext[] contexts) { LocaleDisplayNames result = null; if (FACTORY_DISPLAYCONTEXT != null) { try { result = (LocaleDisplayNames)FACTORY_DISPLAYCONTEXT.Invoke(null, new object[] { locale, contexts }); } catch (TargetInvocationException) { // fall through } //catch (IllegalAccessException e) //{ // // fall through //} } if (result == null) { result = new LastResortLocaleDisplayNames(locale, contexts); } return(result); }
/// <summary> /// Returns an instance of <see cref="LocaleDisplayNames"/> that returns names formatted for the provided <paramref name="locale"/>, /// using the provided <paramref name="dialectHandling"/>. /// </summary> /// <param name="locale">The display locale.</param> /// <param name="dialectHandling">How to select names for locales.</param> /// <returns>A <see cref="LocaleDisplayNames"/> instance.</returns> /// <stable>ICU 4.4</stable> public static LocaleDisplayNames GetInstance(ULocale locale, DialectHandling dialectHandling) { LocaleDisplayNames result = null; if (FACTORY_DIALECTHANDLING != null) { try { result = (LocaleDisplayNames)FACTORY_DIALECTHANDLING.Invoke(null, new object[] { locale, dialectHandling }); } catch (TargetInvocationException) { // fall through } //catch (IllegalAccessException) //{ // // fall through //} } if (result == null) { result = new LastResortLocaleDisplayNames(locale, dialectHandling); } return(result); }