Beispiel #1
0
        //
        // IsValidLcid
        // Lcid is valid if it is built in lcid or synthetic one.
        //

        private static bool IsValidLcid(int lcid, bool canBeCustomLcid)
        {
            if (canBeCustomLcid && CultureTableRecord.IsCustomCultureId(lcid))
            {
                return(true);
            }

            if (CultureTable.Default.IsExistingCulture(lcid))
            {
                return(true);
            }


            return(false);
        }
Beispiel #2
0
        private void OnSerializing(StreamingContext ctx)
        {
            m_nDataItem       = m_cultureTableRecord.EverettDataItem();
            m_useUserOverride = m_cultureTableRecord.UseUserOverride;

            if (CultureTableRecord.IsCustomCultureId(m_cultureTableRecord.CultureID))
            {
                customCultureName = m_cultureTableRecord.SNAME;
                m_win32LangID     = m_textInfoID;
            }
            else
            {
                customCultureName = null;
                m_win32LangID     = m_cultureTableRecord.CultureID;
            }
        }
        public RegionInfo(int culture)
        {
            // Get the culture data item.

            if (culture == CultureInfo.LOCALE_INVARIANT)   //The InvariantCulture has no matching region
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_NoRegionInvariantCulture"));
            }

            if (CultureTableRecord.IsCustomCultureId(culture))   // Customized culture
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber", "culture"));
            }
            if (CultureInfo.GetSubLangID(culture) == 0)
            {
                // Supposed to have sublang (region) info
                throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
            }

            //
            // From this region data item, get the region data item.
            // Several culture ID may map to the same region.
            // For example, 0x1009 (English (Canada)) and 0x0c0c (French (Canada)) all map to
            // the same region "CA" (Canada).
            //
            this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(culture, true);

            if (this.m_cultureTableRecord.IsNeutralCulture)
            {
                // Not supposed to be neutral
                throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
            }

            // Make sure that we initialize m_name since it will be used in deserialization.
            this.m_name = this.m_cultureTableRecord.SREGIONNAME;

            m_cultureId = culture;
        }