Exemple #1
0
        public static CultureInfo[] GetCultures(CultureTypes types)
        {
            bool neutral   = ((types & CultureTypes.NeutralCultures) != 0);
            bool specific  = ((types & CultureTypes.SpecificCultures) != 0);
            bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0);          // TODO

            CultureInfo [] infos = internal_get_cultures(neutral, specific, installed);
            // The runtime returns a NULL in the first position of the array when
            // 'neutral' is true. We fill it in with a clone of InvariantCulture
            // since it must not be read-only
            int i = 0;

            if (neutral && infos.Length > 0 && infos [0] == null)
            {
                infos [i++] = (CultureInfo)InvariantCulture.Clone();
            }

            for (; i < infos.Length; ++i)
            {
                var ci = infos [i];
                var ti = ci.GetTextInfoData();
                infos [i].m_cultureData = CultureData.GetCultureData(ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.number_index, ci.iso2lang,
                                                                     ti.ansi, ti.oem, ti.mac, ti.ebcdic, ti.right_to_left, ((char)ti.list_sep).ToString());
            }

            return(infos);
        }
        public static CultureInfo[] GetCultures(CultureTypes types)
        {
            bool neutral   = ((types & CultureTypes.NeutralCultures) != 0);
            bool specific  = ((types & CultureTypes.SpecificCultures) != 0);
            bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0); // TODO

            CultureInfo [] infos = internal_get_cultures(neutral, specific, installed);
            // The runtime returns a NULL in the first position of the array when
            // 'neutral' is true. We fill it in with a clone of InvariantCulture
            // since it must not be read-only
            if (neutral && infos.Length > 0 && infos [0] == null)
            {
                infos [0] = (CultureInfo)InvariantCulture.Clone();
            }

            return(infos);
        }
Exemple #3
0
        public static CultureInfo[] GetCultures(CultureTypes types)
        {
            bool neutral   = ((types & CultureTypes.NeutralCultures) != 0);
            bool specific  = ((types & CultureTypes.SpecificCultures) != 0);
            bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0);          // TODO

            CultureInfo [] infos = internal_get_cultures(neutral, specific, installed);
            // The runtime returns a NULL in the first position of the array when
            // 'neutral' is true. We fill it in with a clone of InvariantCulture
            // since it must not be read-only
            if (neutral && infos.Length > 0 && infos [0] == null)
            {
                infos [0] = (CultureInfo)InvariantCulture.Clone();
            }

            for (int i = 1; i < infos.Length; ++i)
            {
                var ci = infos [i];
                infos [i].m_cultureData = CultureData.GetCultureData(ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.iso2lang);
            }

            return(infos);
        }