Ejemplo n.º 1
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     _cultureData = cultureData;
     _cultureName = _cultureData.CultureName;
     _textInfoName = _cultureData.STEXTINFO;
     FinishInitialization(_textInfoName);
 }
Ejemplo n.º 2
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public RegionInfo(String name) {
            if (name==null)
                throw new ArgumentNullException("name");

            if (name.Length == 0) //The InvariantCulture has no matching region
            { 
                throw new ArgumentException(Environment.GetResourceString("Argument_NoRegionInvariantCulture"));
            }
            
            Contract.EndContractBlock();

            //
            // First try it as an entire culture. We must have user override as true here so
            // that we can pick up custom cultures *before* built-in ones (if they want to
            // prefer built-in cultures they will pass "us" instead of "en-US").
            //
            this.m_cultureData = CultureData.GetCultureDataForRegion(name,true);
            // this.m_name = name.ToUpper(CultureInfo.InvariantCulture);

            if (this.m_cultureData == null)
                throw new ArgumentException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        Environment.GetResourceString("Argument_InvalidCultureName"), name), "name");


            // Not supposed to be neutral
            if (this.m_cultureData.IsNeutralCulture)
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNeutralRegionName", name), "name");

            SetName(name);
        }
 internal TextInfo(CultureData cultureData)
 {
     this.m_cultureData = cultureData;
     this.m_cultureName = this.m_cultureData.CultureName;
     this.m_textInfoName = this.m_cultureData.STEXTINFO;
     this.m_dataHandle = CompareInfo.InternalInitSortHandle(this.m_textInfoName);
 }
Ejemplo n.º 4
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public RegionInfo(String name)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (name.Length == 0) //The InvariantCulture has no matching region
            {
                throw new ArgumentException(SR.Argument_NoRegionInvariantCulture);
            }

            Contract.EndContractBlock();

            //
            // For CoreCLR we only want the region names that are full culture names
            //
            this.m_cultureData = CultureData.GetCultureDataForRegion(name, true);
            if (this.m_cultureData == null)
                throw new ArgumentException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        SR.Argument_InvalidCultureName, name), "name");


            // Not supposed to be neutral
            if (this.m_cultureData.IsNeutralCulture)
                throw new ArgumentException(SR.Format(SR.Argument_InvalidNeutralRegionName, name), "name");

            SetName(name);
        }
Ejemplo n.º 5
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     // TODO: Implement this fully.
     this.m_cultureData = cultureData;
     this.m_cultureName = this.m_cultureData.CultureName;
     this.m_textInfoName = this.m_cultureData.STEXTINFO;
 }
Ejemplo n.º 6
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     m_cultureData = cultureData;
     m_cultureName = m_cultureData.CultureName;
     m_textInfoName = m_cultureData.STEXTINFO;
     m_needsTurkishCasing = NeedsTurkishCasing(m_textInfoName);
 }
Ejemplo n.º 7
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     // TODO: Implement this fully.
     m_cultureData = cultureData;
     m_cultureName = m_cultureData.CultureName;
     m_textInfoName = m_cultureData.STEXTINFO;
     m_needsTurkishCasing = NeedsTurkishCasing(this.m_textInfoName);
 }
Ejemplo n.º 8
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     // This is our primary data source, we don't need most of the rest of this
     this.m_cultureData = cultureData;
     this.m_cultureName = this.m_cultureData.CultureName;
     this.m_textInfoName = this.m_cultureData.STEXTINFO;
     FinishInitialization(this.m_textInfoName);
 }
        public void TestThatCultureIsSavedAndReturned()
        {
            var culture = new CultureData(CultureInfo.CurrentCulture);

            var entry = new LanguageEntry(culture);

            Assert.AreEqual(culture, entry.Language);
        }
Ejemplo n.º 10
0
        //////////////////////////////////////////////////////////////////////////
        ////
        ////  TextInfo Constructors
        ////
        ////  Implements CultureInfo.TextInfo.
        ////
        //////////////////////////////////////////////////////////////////////////
        internal unsafe TextInfo(CultureData cultureData)
        {
            const uint LCMAP_SORTHANDLE = 0x20000000;

            // This is our primary data source, we don't need most of the rest of this
            _cultureData = cultureData;
            _cultureName = _cultureData.CultureName;
            _textInfoName = _cultureData.STEXTINFO;

            long handle;
            int ret = Interop.mincore.LCMapStringEx(_textInfoName, LCMAP_SORTHANDLE, null, 0, &handle, IntPtr.Size, null, null, IntPtr.Zero);
            _sortHandle = ret > 0 ? (IntPtr)handle : IntPtr.Zero;
        }
        private void OnDeserialized(StreamingContext ctx)
        {
            if (this.m_name != null)
            {
                m_cultureData = CultureData.GetCultureData(m_name, m_useUserOverride);
                // 
                if (this.m_cultureData == null)
                    throw new CultureNotFoundException(
                        "m_name", m_name, Environment.GetResourceString("Argument_CultureNotSupported"));
            }
            // Note: This is for Everett compatibility
            // 
#if FEATURE_USE_LCID
            else
                m_cultureData = CultureData.GetCultureData(CultureID, m_useUserOverride);
#endif
            if (calendar == null)
            {
                calendar = (Calendar) GregorianCalendar.GetDefaultInstance().Clone();
                calendar.SetReadOnlyState(m_isReadOnly);
            }
            else
            {
                CultureInfo.CheckDomainSafetyObject(calendar, this);
            }
            InitializeOverridableProperties(m_cultureData, calendar.ID);

            //
            //  turn off read only state till we finish initializing all fields and then store read only state after we are done.
            //
            bool isReadOnly = m_isReadOnly;
            m_isReadOnly = false;

            // If we deserialized defaults ala Whidbey, make sure they're still defaults
            // Whidbey's arrays could get a bit mixed up.
            if (longDatePattern  != null) this.LongDatePattern  = longDatePattern;
            if (shortDatePattern != null) this.ShortDatePattern = shortDatePattern;
            if (yearMonthPattern != null) this.YearMonthPattern = yearMonthPattern;
            if (longTimePattern  != null) this.LongTimePattern  = longTimePattern;
            if (shortTimePattern != null) this.ShortTimePattern = shortTimePattern;
            
            m_isReadOnly = isReadOnly;
        }
Ejemplo n.º 12
0
 internal static extern bool nativeInitCultureData(CultureData cultureData);
Ejemplo n.º 13
0
        private void OnDeserialized(StreamingContext ctx)
        {
#if FEATURE_CORECLR            
            // This won't happen anyway since CoreCLR doesn't support serialization
            this.m_cultureData = CultureData.GetCultureData(m_name, true);
#else
            if (m_name == null)
            {
                Contract.Assert(m_dataItem >= 0, "[RegionInfo.OnDeserialized] null name and invalid dataItem");
                m_cultureId = IdFromEverettRegionInfoDataItem[m_dataItem];
            }

            if (m_cultureId == 0)
            {
                this.m_cultureData = CultureData.GetCultureDataForRegion(this.m_name, true);
            }
            else
            {
                this.m_cultureData = CultureData.GetCultureData(m_cultureId, true);
            }
                
#endif
            if (this.m_cultureData == null)
                throw new ArgumentException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        Environment.GetResourceString("Argument_InvalidCultureName"), m_name), "m_name");

            if (m_cultureId == 0)
            {
                SetName(this.m_name);
            }
            else
            {
                this.m_name = this.m_cultureData.SREGIONNAME;
            }
        }
Ejemplo n.º 14
0
        private static CultureData CreateCultureData(string cultureName, bool useUserOverride)
        {
            CultureData culture = new CultureData();
            culture._bUseOverrides = useUserOverride;
            culture._sRealName = cultureName;

            // Ask native code if that one's real
            if (culture.InitCultureData() == false)
            {
                if (culture.InitCompatibilityCultureData() == false)
                {
                    return null;
                }
            }

            return culture;
        }
Ejemplo n.º 15
0
        private void OnDeserialized()
        {
            // this method will be called twice because of the support of IDeserializationCallback
            if (this.m_cultureData == null)
            {
                if (this.m_cultureName == null)
                {
                    // This is whidbey data, get it from customCultureName/win32langid               
                    if (this.customCultureName != null)
                    {
                        // They gave a custom cultuer name, so use that
                        this.m_cultureName = this.customCultureName; 
                    }
#if FEATURE_USE_LCID
                    else
                    {
                        if (m_win32LangID == 0)
                        {
                            // m_cultureName and m_win32LangID are nulls which means we got uninitialized textinfo serialization stream. 
                            // To be compatible with v2/3/3.5 we need to return ar-SA TextInfo in this case.
                            m_cultureName = "ar-SA";
                        }
                        else
                        {
                            // No custom culture, use the name from the LCID
                            m_cultureName = CultureInfo.GetCultureInfo(m_win32LangID).m_cultureData.CultureName;
                        }
                    }
#endif
                }
                
                // Get the text info name belonging to that culture
                this.m_cultureData = CultureInfo.GetCultureInfo(m_cultureName).m_cultureData;
                this.m_textInfoName = this.m_cultureData.STEXTINFO;
#if !FEATURE_CORECLR
                IntPtr handleOrigin;
                this.m_dataHandle = CompareInfo.InternalInitSortHandle(m_textInfoName, out handleOrigin);
                this.m_handleOrigin = handleOrigin;
#endif
            }            
        }
Ejemplo n.º 16
0
 private void OnDeserializing(StreamingContext ctx) 
 { 
     // Clear these so we can check if we've fixed them yet            
     this.m_cultureData = null;
     this.m_cultureName = null;            
 }   
Ejemplo n.º 17
0
        ////////////////////////////////////////////////////////////////////////
        //
        //  TextInfo Constructors
        //
        //  Implements CultureInfo.TextInfo.
        //
        ////////////////////////////////////////////////////////////////////////
        internal TextInfo(CultureData cultureData) 
        {
            // This is our primary data source, we don't need most of the rest of this
            this.m_cultureData = cultureData;
            this.m_cultureName = this.m_cultureData.CultureName;
            this.m_textInfoName = this.m_cultureData.STEXTINFO;
#if !FEATURE_CORECLR
            IntPtr handleOrigin;
            this.m_dataHandle = CompareInfo.InternalInitSortHandle(m_textInfoName, out handleOrigin);
            this.m_handleOrigin = handleOrigin;
#endif
        }
Ejemplo n.º 18
0
        private void InitializeFromCultureId(int culture, bool useUserOverride)
        {
            switch (culture)
            {
                case LOCALE_CUSTOM_DEFAULT:
                case LOCALE_SYSTEM_DEFAULT:
                case LOCALE_NEUTRAL:
                case LOCALE_USER_DEFAULT:
                case LOCALE_CUSTOM_UNSPECIFIED:
                    // Can't support unknown custom cultures and we do not support neutral or
                    // non-custom user locales.
                    throw new CultureNotFoundException("culture", culture, SR.Argument_CultureNotSupported);

                default:
                    // Now see if this LCID is supported in the system default CultureData table.
                    m_cultureData = CultureData.GetCultureData(culture, useUserOverride);
                    break;
            }
            m_isInherited = (this.GetType() != typeof(System.Globalization.CultureInfo));
            m_name = m_cultureData.CultureName;
        }
Ejemplo n.º 19
0
        // Constructor called by SQL Server's special munged culture - creates a culture with
        // a TextInfo and CompareInfo that come from a supplied alternate source. This object
        // is ALWAYS read-only.
        // Note that we really cannot use an LCID version of this override as the cached
        // name we create for it has to include both names, and the logic for this is in
        // the GetCultureInfo override *only*.
        internal CultureInfo(String cultureName, String textAndCompareCultureName)
        {
            if (cultureName == null)
            {
                throw new ArgumentNullException("cultureName",SR.ArgumentNull_String);
            }
            Contract.EndContractBlock();

            m_cultureData = CultureData.GetCultureData(cultureName, false);
            if (m_cultureData == null)
                throw new CultureNotFoundException("cultureName", cultureName, SR.Argument_CultureNotSupported);
            
            m_name = m_cultureData.CultureName;

            CultureInfo altCulture = GetCultureInfo(textAndCompareCultureName);
            compareInfo = altCulture.CompareInfo;
            textInfo = altCulture.TextInfo;
        }
Ejemplo n.º 20
0
		private CultureInfo (string name, bool useUserOverride, bool read_only)
		{
			if (name == null)
				throw new ArgumentNullException ("name");

			constructed = true;
			m_isReadOnly = read_only;
			m_useUserOverride = useUserOverride;
			m_isInherited = GetType() != typeof(System.Globalization.CultureInfo);

			if (name.Length == 0) {
				/* Short circuit the invariant culture */
				m_cultureData = CultureData.Invariant;
				ConstructInvariant (read_only);
				return;
			}

			if (!construct_internal_locale_from_name (name.ToLowerInvariant ())) {
				throw CreateNotFoundException (name);
			}

			var ti = GetTextInfoData ();
			m_cultureData = CultureData.GetCultureData (m_name, useUserOverride, datetime_index, CalendarType, number_index, iso2lang,
				ti.ansi, ti.oem, ti.mac, ti.ebcdic, ti.right_to_left, ((char)ti.list_sep).ToString ());
		}
Ejemplo n.º 21
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 internal RegionInfo(CultureData cultureData)
 {
     this.m_cultureData = cultureData;
     this.m_name = this.m_cultureData.SREGIONNAME;
 }
Ejemplo n.º 22
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public RegionInfo(int culture)
        {
            if (culture == CultureInfo.LOCALE_INVARIANT) //The InvariantCulture has no matching region
            { 
                throw new ArgumentException(Environment.GetResourceString("Argument_NoRegionInvariantCulture"));
            }
            
            if (culture == CultureInfo.LOCALE_NEUTRAL)
            {
                // Not supposed to be neutral
                throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
            }

            if (culture == CultureInfo.LOCALE_CUSTOM_DEFAULT)
            {
                // Not supposed to be neutral
                throw new ArgumentException(Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber", culture), "culture");
            }
            
            this.m_cultureData = CultureData.GetCultureData(culture,true);
            this.m_name = this.m_cultureData.SREGIONNAME;

            if (this.m_cultureData.IsNeutralCulture)
            {
                // Not supposed to be neutral
                throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
            }
            m_cultureId = culture;
        }
Ejemplo n.º 23
0
 //////////////////////////////////////////////////////////////////////////
 ////
 ////  TextInfo Constructors
 ////
 ////  Implements CultureInfo.TextInfo.
 ////
 //////////////////////////////////////////////////////////////////////////
 internal unsafe TextInfo(CultureData cultureData)
 {
     // TODO: Implement this fully.
 }
Ejemplo n.º 24
0
		private CultureInfo (int culture, bool useUserOverride, bool read_only)
		{
			if (culture < 0)
				throw new ArgumentOutOfRangeException ("culture", "Positive "
					+ "number required.");

			constructed = true;
			m_isReadOnly = read_only;
			m_useUserOverride = useUserOverride;

			if (culture == InvariantCultureId) {
				/* Short circuit the invariant culture */
				ConstructInvariant (read_only);
				m_cultureData = CultureData.Invariant;
				return;
			}

			if (!construct_internal_locale_from_lcid (culture)) {
				//
				// Be careful not to cause recursive CultureInfo initialization
				//
				var msg = string.Format (InvariantCulture, "Culture ID {0} (0x{1}) is not a supported culture.", culture.ToString (InvariantCulture), culture.ToString ("X4", InvariantCulture));
				throw new CultureNotFoundException ("culture", msg);
			}

			m_cultureData = CultureData.GetCultureData (m_name, m_useUserOverride, datetime_index, CalendarType, iso2lang);
		}
Ejemplo n.º 25
0
        private void InitializeFromName(string name, bool useUserOverride)
        {
            // Get our data providing record
            this.m_cultureData = CultureData.GetCultureData(name, useUserOverride);

            if (this.m_cultureData == null)
            {
                throw new CultureNotFoundException("name", name, SR.Argument_CultureNotSupported);
            }

            this.m_name = this.m_cultureData.CultureName;
            this.m_isInherited = (this.GetType() != typeof(System.Globalization.CultureInfo));
        }
Ejemplo n.º 26
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal NumberFormatInfo(CultureData cultureData)
        {
            if (cultureData != null)
            {
                // We directly use fields here since these data is coming from data table or Win32, so we
                // don't need to verify their values (except for invalid parsing situations).
                cultureData.GetNFIValues(this);

                if (cultureData.IsInvariantCulture)
                {
                    // For invariant culture
                    this.m_isInvariant = true;
                }
            }
        }
Ejemplo n.º 27
0
		private CultureInfo (string name, bool useUserOverride, bool read_only)
		{
			if (name == null)
				throw new ArgumentNullException ("name");

			constructed = true;
			m_isReadOnly = read_only;
			m_useUserOverride = useUserOverride;
			m_isInherited = GetType() != typeof(System.Globalization.CultureInfo);

			if (name.Length == 0) {
				/* Short circuit the invariant culture */
				ConstructInvariant (read_only);
				m_cultureData = CultureData.Invariant;
				return;
			}

			if (!construct_internal_locale_from_name (name.ToLowerInvariant ())) {
				throw CreateNotFoundException (name);
			}

			m_cultureData = CultureData.GetCultureData (m_name, useUserOverride, datetime_index, CalendarType, iso2lang);
		}
        internal DateTimeFormatInfo(CultureData cultureData, Calendar cal)
        {
            Contract.Requires(cultureData != null);
            Contract.Requires(cal != null);

            // Remember our culture
            this.m_cultureData = cultureData;

            // m_isDefaultCalendar is set in the setter of Calendar below.
            this.Calendar = cal;
        }
Ejemplo n.º 29
0
        private static CultureData CreateCultureData(string cultureName, bool useUserOverride)
        {
            CultureData culture = new CultureData();
            culture.bUseOverrides = useUserOverride;
            culture.sRealName = cultureName;

            // Ask native code if that one's real
            if (culture.InitCultureData() == false)
            {
#if !FEATURE_CORECLR
                if (culture.InitCompatibilityCultureData() == false
                 && culture.InitLegacyAlternateSortData() == false)
#endif
                {
                    return null;
                }
            }

            return culture;
        }
        private void InitializeOverridableProperties(CultureData cultureData, int calendarID)
        {
#if !FEATURE_CORECLR
            // Silverlight 2.0 never took a snapshot of the user's overridable properties
            // This has a substantial performance impact so skip when CoreCLR
            Contract.Requires(cultureData != null);
            Contract.Assert(calendarID > 0, "[DateTimeFormatInfo.Populate] Expected Calendar.ID > 0");

            if (this.firstDayOfWeek == -1) { this.firstDayOfWeek = cultureData.IFIRSTDAYOFWEEK; }
            if (this.calendarWeekRule == -1) { this.calendarWeekRule = cultureData.IFIRSTWEEKOFYEAR; }

            if (this.amDesignator == null) { this.amDesignator = cultureData.SAM1159; }
            if (this.pmDesignator == null) { this.pmDesignator = cultureData.SPM2359; }
            if (this.timeSeparator == null) { this.timeSeparator = cultureData.TimeSeparator; }
            if (this.dateSeparator == null) { this.dateSeparator = cultureData.DateSeparator(calendarID); }

            this.allLongTimePatterns = this.m_cultureData.LongTimes;
            Contract.Assert(this.allLongTimePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some long time patterns");

            this.allShortTimePatterns = this.m_cultureData.ShortTimes;
            Contract.Assert(this.allShortTimePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some short time patterns");

            this.allLongDatePatterns = cultureData.LongDates(calendarID);
            Contract.Assert(this.allLongDatePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some long date patterns");

            this.allShortDatePatterns = cultureData.ShortDates(calendarID);
            Contract.Assert(this.allShortDatePatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some short date patterns");

            this.allYearMonthPatterns = cultureData.YearMonths(calendarID);
            Contract.Assert(this.allYearMonthPatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some year month patterns");
#endif
        }