Beispiel #1
0
        /// <summary>
        /// Utility for <see cref="GetMeasurementSystem(ULocale)"/> and <see cref="GetPaperSize(ULocale)"/>
        /// </summary>
        private static UResourceBundle MeasurementTypeBundleForLocale(ULocale locale, string measurementType)
        {
            // Much of this is taken from getCalendarType in impl/CalendarUtil.java
            UResourceBundle measTypeBundle = null;

#pragma warning disable 612, 618
            string region = ULocale.GetRegionForSupplementalData(locale, true);
#pragma warning restore 612, 618
            try
            {
                UResourceBundle rb = UResourceBundle.GetBundleInstance(
                    ICUData.IcuBaseName,
                    "supplementalData",
                    ICUResourceBundle.IcuDataAssembly);
                UResourceBundle measurementData = rb.Get("measurementData");
                UResourceBundle measDataBundle  = null;
                try
                {
                    measDataBundle = measurementData.Get(region);
                    measTypeBundle = measDataBundle.Get(measurementType);
                }
                catch (MissingManifestResourceException)
                {
                    // use "001" as fallback
                    measDataBundle = measurementData.Get("001");
                    measTypeBundle = measDataBundle.Get(measurementType);
                }
            }
            catch (MissingManifestResourceException)
            {
                // fall through
            }
            return(measTypeBundle);
        }
Beispiel #2
0
        /**
         * Utility for getMeasurementSystem and getPaperSize
         */
        private static UResourceBundle MeasurementTypeBundleForLocale(ULocale locale, string measurementType)
        {
            // Much of this is taken from getCalendarType in impl/CalendarUtil.java
            UResourceBundle measTypeBundle = null;
            string          region         = ULocale.GetRegionForSupplementalData(locale, true);

            try
            {
                UResourceBundle rb = UResourceBundle.GetBundleInstance(
                    ICUData.ICU_BASE_NAME,
                    "supplementalData",
                    ICUResourceBundle.ICU_DATA_CLASS_LOADER);
                UResourceBundle measurementData = rb.Get("measurementData");
                UResourceBundle measDataBundle  = null;
                try
                {
                    measDataBundle = measurementData.Get(region);
                    measTypeBundle = measDataBundle.Get(measurementType);
                }
                catch (MissingManifestResourceException mre)
                {
                    // use "001" as fallback
                    measDataBundle = measurementData.Get("001");
                    measTypeBundle = measDataBundle.Get(measurementType);
                }
            }
            catch (MissingManifestResourceException mre)
            {
                // fall through
            }
            return(measTypeBundle);
        }