Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.NumberFormatDigital" /> class.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <param name="partLocaleID">The part locale ID.</param>
        /// <param name="dbNumberFormatPart">The number format part.</param>
        /// <param name="culture">The culture.</param>
        public NumberFormatDigital(string format, object partLocaleID, object dbNumberFormatPart, CultureInfo culture) : base(partLocaleID, dbNumberFormatPart, culture)
        {
            this.excelFormatString = string.Empty;
            string s = NumberFormatBase.TrimNotSupportSymbol(format);

            this.fullFormatString  = DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket);
            this.excelFormatString = s;
            if (partLocaleID != null)
            {
                string str2 = s;
                s = DefaultTokens.ReplaceKeyword(str2, base.PartLocaleID.OriginalToken, base.PartLocaleID.CurrencySymbol);
            }
            if (base.PartDBNumberFormat != null)
            {
                this.excelFormatString = DefaultTokens.ReplaceKeyword(this.excelFormatString, base.PartDBNumberFormat.OriginalToken, base.PartDBNumberFormat.ToString());
            }
            s = DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket);
            if (s.IndexOf(DefaultTokens.SolidusSign) > -1)
            {
                s = s.Replace(DefaultTokens.QuestionMark, DefaultTokens.Zero);
                string[] strArray = DefaultTokens.Split(s, DefaultTokens.SolidusSign);
                if ((strArray != null) && (strArray.Length == 2))
                {
                    this.fractionDenominatorFormat = strArray[1];
                    string[] integerAndNumeratorParts = this.GetIntegerAndNumeratorParts(strArray[0]);
                    if ((integerAndNumeratorParts != null) && (integerAndNumeratorParts.Length == 3))
                    {
                        this.fractionIntegerFormat   = integerAndNumeratorParts[0];
                        this.constString             = integerAndNumeratorParts[1];
                        this.fractionNumeratorFormat = integerAndNumeratorParts[2];
                    }
                }
            }
            this.numberFormatString = s;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.NumberFormatDateTime" /> class.
        /// </summary>
        /// <param name="format">The format</param>
        /// <param name="absTimeParts">The abs time parts.</param>
        /// <param name="partLocaleID">The part locale ID.</param>
        /// <param name="dbNumberFormatPart">The db number format part.</param>
        /// <param name="culture">The culture.</param>
        internal NumberFormatDateTime(string format, ABSTimeFormatPart[] absTimeParts, object partLocaleID, object dbNumberFormatPart, CultureInfo culture) : base(partLocaleID, dbNumberFormatPart, culture)
        {
            this.absoluteTime = null;
            this.ExactlyMatch = false;
            this.formatString = this.FixFormat(NumberFormatBase.TrimNotSupportSymbol(format));
            string formatString = this.formatString;

            this.absTimeParts = absTimeParts;
            if (!EvaluateFormat(formatString))
            {
                throw new ArgumentException(ResourceStrings.FormatIllegalFormatError);
            }
            bool flag = this.ProcessAMPM(ref formatString);

            this.hasJD = this.Replace(formatString, MonthJD, "\"" + PlaceholderMonthJD + "\"", true, false, out formatString, false, false);
            this.Replace(formatString, MonthUnabbreviated, StandardMonthUnabbreviated, true, false, out formatString, false, false);
            this.Replace(formatString, MonthAbbreviation, StandardMonthAbbreviation, true, false, out formatString, false, false);
            this.Replace(formatString, MonthTwoDigit, StandardMonthTwoDigit, true, false, out formatString, false, false);
            this.Replace(formatString, MonthSingleDigit, StandardMonthSingleDigit, true, false, out formatString, false, false);
            this.Replace(formatString, DayWeekDayAbbreviation, StandardDayWeekDayAbbreviation, true, true, out formatString, false, true);
            this.Replace(formatString, DayWeekDayUnabbreviated, StandardDayWeekDayUnabbreviated, true, true, out formatString, false, true);
            this.Replace(formatString, MinuteSingleDigit, StandardMinuteSingleDigit, false, true, out formatString, false, false);
            if (!flag)
            {
                this.Replace(formatString, HoursSingleDigit, StandardHourSingleDigit, true, true, out formatString, false, false);
                this.Replace(formatString, HoursTwoDigit, StandardHourTwoDigit, true, true, out formatString, false, false);
            }
            this.Replace(formatString, SecondSingleDigit, StandardSecondSingleDigit, true, true, out formatString, false, true);
            this.Replace(formatString, SubSecondThreeDigit, StandardSubSecondThreeDigit, true, true, out formatString, false, true);
            this.Replace(formatString, SubSecondTwoDigit, StandardSubSecondTwoDigit, true, true, out formatString, false, true);
            this.Replace(formatString, SubSecondSingleDigit, StandardSubSecondSingleDigit, true, true, out formatString, false, true);
            if ((base.PartDBNumberFormat != null) && (base.PartLocaleID != null))
            {
                this.hasYearDelay |= this.Replace(formatString, YearFourDigit, "\"" + DefaultTokens.ReplacePlaceholder + YearFourDigit + "\"", true, false, out formatString, false, true);
                this.hasYearDelay |= this.Replace(formatString, YearTwoDigit, "\"" + DefaultTokens.ReplacePlaceholder + YearTwoDigit + "\"", true, false, out formatString, false, true);
            }
            if (this.IsJanpaneseCulture())
            {
                this.Replace(formatString, EraYear, YearSingleDigit, true, false, out formatString, false, true);
                this.Replace(formatString, EraYear + EraYear, YearTwoDigit, true, false, out formatString, false, true);
                this.Replace(formatString, EraYear + EraYear + EraYear, YearTwoDigit, true, false, out formatString, false, true);
            }
            else
            {
                this.Replace(formatString, EraYear, YearFourDigit, true, false, out formatString, false, true);
                this.Replace(formatString, EraYear + EraYear, YearFourDigit, true, false, out formatString, false, true);
                this.Replace(formatString, EraYear + EraYear + EraYear, YearFourDigit, true, false, out formatString, false, true);
            }
            this.Replace(formatString, YearSingleDigit, StandardYearSingleDigit, true, false, out formatString, false, true);
            if (this.absTimeParts != null)
            {
                foreach (ABSTimeFormatPart part in this.absTimeParts)
                {
                    this.Replace(formatString, part.Token, "\"" + DefaultTokens.ReplacePlaceholder + part.Token + "\"", true, true, out formatString, false, true);
                }
            }
            this.validDateTimeFormatString = formatString;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.NumberFormatText" /> class.
        /// </summary>
        /// <param name="format">The format string</param>
        /// <param name="partLocaleID">The part locale ID.</param>
        /// <param name="dbNumberFormatPart">The db number format part.</param>
        /// <param name="culture">The culture.</param>
        internal NumberFormatText(string format, object partLocaleID, object dbNumberFormatPart, CultureInfo culture) : base(partLocaleID, dbNumberFormatPart, culture)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }
            string s = NumberFormatBase.TrimNotSupportSymbol(format, false);

            if (partLocaleID != null)
            {
                s = DefaultTokens.ReplaceKeyword(s, base.PartLocaleID.OriginalToken, base.PartLocaleID.CurrencySymbol);
            }
            this.excelFormatString = s;
            s = DefaultTokens.TrimEscape(DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket));
            this.formatString = s;
        }