System.Globalization.CultureTableRecord.GetNFIOverrideValues C# (CSharp) Method

GetNFIOverrideValues() private method

private GetNFIOverrideValues ( NumberFormatInfo nfi ) : void
nfi NumberFormatInfo
return void
        internal unsafe void GetNFIOverrideValues(NumberFormatInfo nfi) {
            bool result = false;
            if (UseGetLocaleInfo) {
                result = CultureInfo.nativeGetNFIUserValues(InteropLCID, nfi);
            }

            if (!result) {
                // Something failed during the call to GetLocaleInfo().  Use the information in culture.nlp.
                nfi.numberDecimalDigits     = IDIGITS;
                nfi.numberNegativePattern   = INEGNUMBER;
                nfi.currencyDecimalDigits   = ICURRDIGITS;
                nfi.currencyPositivePattern = ICURRENCY;
                nfi.currencyNegativePattern = INEGCURR;
                nfi.negativeSign            = SNEGATIVESIGN;
                nfi.numberDecimalSeparator  = SDECIMAL;
                nfi.numberGroupSeparator    = STHOUSAND;
                nfi.positiveSign            = SPOSITIVESIGN;
                nfi.currencyDecimalSeparator= SMONDECIMALSEP;
                nfi.currencySymbol          = SCURRENCY;
                nfi.currencyGroupSeparator  = SMONTHOUSANDSEP;
                nfi.nativeDigits            = SNATIVEDIGITS;
                nfi.digitSubstitution       = IDIGITSUBSTITUTION;
            }
            else if(-1 == nfi.digitSubstitution) {
                // This is a Win2000 and above property, so when it is marked as -1
                // (an invalid value) we know it failed for Win9x reasons and that
                // we should fall back to getting this infotmation from culture.nlp.
                nfi.digitSubstitution       = IDIGITSUBSTITUTION;
            }

            nfi.numberGroupSizes        = SGROUPING;
            nfi.currencyGroupSizes      = SMONGROUPING;

            nfi.percentDecimalDigits    = nfi.numberDecimalDigits;
            nfi.percentDecimalSeparator = nfi.numberDecimalSeparator;
            nfi.percentGroupSizes       = nfi.numberGroupSizes;
            nfi.percentGroupSeparator   = nfi.numberGroupSeparator;
            nfi.percentNegativePattern  = INEGATIVEPERCENT;
            nfi.percentPositivePattern  = IPOSITIVEPERCENT;
            nfi.percentSymbol           = SPERCENT;

            if (nfi.positiveSign == null || nfi.positiveSign.Length == 0) nfi.positiveSign = "+";

            if (nfi.currencyDecimalSeparator.Length==0) {
                nfi.currencyDecimalSeparator= SMONDECIMALSEP;
            }


        }

Usage Example

        // We aren't persisting dataItem any more (since its useless & we weren't using it),
        // Ditto with m_useUserOverride.  Don't use them, we use a local copy of everything.
        internal NumberFormatInfo(CultureTableRecord cultureTableRecord)
        {
            if (cultureTableRecord != null)
            {
                /*
                We don't have information for the following four.  All cultures use
                the same value set in the ctor of NumberFormatInfo.
                PercentGroupSize
                PercentDecimalDigits
                PercentGroupSeparator
                PerMilleSymbol
                */

                // 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).

                cultureTableRecord.GetNFIOverrideValues(this);

                if((932 == cultureTableRecord.IDEFAULTANSICODEPAGE) ||
                   (949 == cultureTableRecord.IDEFAULTANSICODEPAGE)) {
                    // Legacy behavior for cultures that use Japaanese/Korean default ANSI code pages
                    this.ansiCurrencySymbol  = "\\";
                }
                this.negativeInfinitySymbol  = cultureTableRecord.SNEGINFINITY;
                this.positiveInfinitySymbol  = cultureTableRecord.SPOSINFINITY;
                this.nanSymbol               = cultureTableRecord.SNAN;
            }
        }