Example #1
0
        // Get an array of all cultures in the system.
        public CultureInfo[] GetCultures(CultureTypes types)
        {
            // Count the number of culture handlers in the system.
            int count = 0;

            if ((types & CultureTypes.NeutralCultures) != 0)
            {
                ++count;
            }
            IDictionaryEnumerator e = handlers.GetEnumerator();
            String name;

            while (e.MoveNext())
            {
                name = (String)(e.Key);
                if (CultureMatch(name, types))
                {
                    ++count;
                }
            }

            // Build the list of cultures.
            CultureInfo[] cultures = new CultureInfo [count];
            count = 0;
            if ((types & CultureTypes.NeutralCultures) != 0)
            {
                cultures[count++] = CultureInfo.InvariantCulture;
            }
            e.Reset();
            while (e.MoveNext())
            {
                name = (String)(e.Key);
                if (CultureMatch(name, types))
                {
                    cultures[count++] =
                        new CultureInfo(FromHex(name, 3));
                }
            }

            // Return the culture list to the caller.
            return(cultures);
        }