Ejemplo n.º 1
0
        public virtual CurrencyDisplayInfo GetInstance(UCultureInfo culture, bool withFallback)
        {
            // Make sure the locale is non-null (this can happen during deserialization):
            if (culture == null)
            {
                culture = UCultureInfo.InvariantCulture;
            }
            ICUCurrencyDisplayInfo instance = currencyDisplayInfoCache;

            if (instance == null || !culture.Equals(instance.culture) || instance.fallback != withFallback)
            {
                ICUResourceBundle rb;
                if (withFallback)
                {
                    rb = ICUResourceBundle.GetBundleInstance(ICUData.IcuCurrencyBaseName, culture, ICUResourceBundle.IcuDataAssembly, OpenType.LocaleDefaultRoot);
                }
                else
                {
                    try
                    {
                        rb = ICUResourceBundle.GetBundleInstance(ICUData.IcuCurrencyBaseName, culture, ICUResourceBundle.IcuDataAssembly, OpenType.LocaleOnly);
                    }
                    catch (MissingManifestResourceException)
                    {
                        return(null);
                    }
                }
                instance = new ICUCurrencyDisplayInfo(culture, rb, withFallback);
                currencyDisplayInfoCache = instance;
            }
            return(instance);
        }
        public virtual CurrencyDisplayInfo GetInstance(ULocale locale, bool withFallback)
        {
            // Make sure the locale is non-null (this can happen during deserialization):
            if (locale == null)
            {
                locale = ULocale.ROOT;
            }
            ICUCurrencyDisplayInfo instance = currencyDisplayInfoCache;

            if (instance == null || !instance.locale.Equals(locale) || instance.fallback != withFallback)
            {
                ICUResourceBundle rb;
                if (withFallback)
                {
                    rb = ICUResourceBundle.GetBundleInstance(
                        ICUData.ICU_CURR_BASE_NAME, locale, typeof(ICUCurrencyDisplayInfoProvider).GetTypeInfo().Assembly, OpenType.LOCALE_DEFAULT_ROOT);
                }
                else
                {
                    try
                    {
                        rb = ICUResourceBundle.GetBundleInstance(
                            ICUData.ICU_CURR_BASE_NAME, locale, typeof(ICUCurrencyDisplayInfoProvider).GetTypeInfo().Assembly, OpenType.LOCALE_ONLY);
                    }
                    catch (MissingManifestResourceException e)
                    {
                        return(null);
                    }
                }
                instance = new ICUCurrencyDisplayInfo(locale, rb, withFallback);
                currencyDisplayInfoCache = instance;
            }
            return(instance);
        }
Ejemplo n.º 3
0
        public virtual CurrencyDisplayInfo GetInstance(ULocale locale, bool withFallback)
        {
            // Make sure the locale is non-null (this can happen during deserialization):
            if (locale == null)
            {
                locale = ULocale.ROOT;
            }
            ICUCurrencyDisplayInfo instance = currencyDisplayInfoCache;

            if (instance == null || !instance.locale.Equals(locale) || instance.fallback != withFallback)
            {
                ICUResourceBundle rb;
#if FEATURE_TYPEEXTENSIONS_GETTYPEINFO
                Assembly assembly = typeof(ICUCurrencyDisplayInfoProvider).GetTypeInfo().Assembly;
#else
                Assembly assembly = typeof(ICUCurrencyDisplayInfoProvider).Assembly;
#endif
                if (withFallback)
                {
                    rb = ICUResourceBundle.GetBundleInstance(ICUData.IcuCurrencyBaseName, locale, assembly, OpenType.LocaleDefaultRoot);
                }
                else
                {
                    try
                    {
                        rb = ICUResourceBundle.GetBundleInstance(ICUData.IcuCurrencyBaseName, locale, assembly, OpenType.LocaleOnly);
                    }
                    catch (MissingManifestResourceException)
                    {
                        return(null);
                    }
                }
                instance = new ICUCurrencyDisplayInfo(locale, rb, withFallback);
                currencyDisplayInfoCache = instance;
            }
            return(instance);
        }