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 override int Compare(string x, string y)
        {
            if (stemBase)
            {
                x = x.StemCompareBase();
                y = y.StemCompareBase();
            }
            if (x == y || InvariantCulture.Compare(x, y) == 0)
            {
                return(0);
            }
            var p1 = Split(x);
            var p2 = Split(y);

            int rv;
            var e = Math.Min(p1.Length, p2.Length);

            for (var i = 0; i < e; ++i)
            {
                rv = p1[i].CompareTo(p2[i]);
                if (rv != 0)
                {
                    return(rv);
                }
            }
            rv = p1.Length.CompareTo(p2.Length);
            if (rv == 0)
            {
                return(comparer.Compare(x, y));
            }
            return(rv);
        }
        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 #4
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);
        }