예제 #1
0
        public EcmaValue ToValue()
        {
            EcmaObject obj = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Type, IntlProviderOptions.ToStringValue(this.Type));
            obj.CreateDataPropertyOrThrow(PropertyKey.Value, this.Value);
            return(obj);
        }
예제 #2
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            ListFormat formatter = thisValue.GetUnderlyingObject <ListFormat>(); EcmaObject obj = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, formatter.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.Style, IntlProviderOptions.ToStringValue(formatter.Style));
            obj.CreateDataPropertyOrThrow(PropertyKey.Type, IntlProviderOptions.ToStringValue(formatter.Type));
            return(obj);
        }
예제 #3
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            RelativeTimeFormat formatter = thisValue.GetUnderlyingObject <RelativeTimeFormat>();
            EcmaObject         obj       = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, formatter.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.Style, IntlProviderOptions.ToStringValue(formatter.Style));
            obj.CreateDataPropertyOrThrow(PropertyKey.Numeric, IntlProviderOptions.ToStringValue(formatter.Numeric));
            obj.CreateDataPropertyOrThrow(PropertyKey.NumberingSystem, formatter.NumberingSystem);
            return(obj);
        }
예제 #4
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            PluralRules      rules      = thisValue.GetUnderlyingObject <PluralRules>();
            List <EcmaValue> categories = new List <EcmaValue>();

            foreach (KeyValuePair <string, PluralCategories> e in StringValueMap <PluralCategories> .Default.Forward)
            {
                if ((rules.PluralCategories & e.Value) != 0)
                {
                    categories.Add(e.Key);
                }
            }
            EcmaObject obj = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, rules.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.PluralCategories, new EcmaArray(categories));
            obj.CreateDataPropertyOrThrow(PropertyKey.Type, IntlProviderOptions.ToStringValue(rules.Type));
            if (rules.Digits.UseSignificantDigits)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumSignificantDigits, rules.Digits.MinimumSignificantDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MaximumSignificantDigits, rules.Digits.MaximumSignificantDigits);
            }
            else
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumIntegerDigits, rules.Digits.MinimumSignificantDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumFractionDigits, rules.Digits.MinimumFractionDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MaximumFractionDigits, rules.Digits.MaximumFractionDigits);
            }
            return(obj);
        }
예제 #5
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            Collator   collator = thisValue.GetUnderlyingObject <Collator>();
            EcmaObject obj      = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, collator.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.Usage, IntlProviderOptions.ToStringValue(collator.Usage));
            obj.CreateDataPropertyOrThrow(PropertyKey.Sensitivity, IntlProviderOptions.ToStringValue(collator.Sensitivity));
            obj.CreateDataPropertyOrThrow(PropertyKey.IgnorePunctuation, collator.IgnorePunctuation);
            obj.CreateDataPropertyOrThrow(PropertyKey.Collation, collator.Collation);
            obj.CreateDataPropertyOrThrow(PropertyKey.Numeric, collator.Numeric);
            obj.CreateDataPropertyOrThrow(PropertyKey.CaseFirst, IntlProviderOptions.ToStringValue(collator.CaseFirst));
            return(obj);
        }
예제 #6
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            NumberFormat formatter = thisValue.GetUnderlyingObject <NumberFormat>();
            EcmaObject   obj       = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, formatter.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.NumberingSystem, formatter.NumberingSystem);
            obj.CreateDataPropertyOrThrow(PropertyKey.Style, IntlProviderOptions.ToStringValue(formatter.Style));
            obj.CreateDataPropertyOrThrow(PropertyKey.Notation, IntlProviderOptions.ToStringValue(formatter.Notation));
            obj.CreateDataPropertyOrThrow(PropertyKey.CompactDisplay, IntlProviderOptions.ToStringValue(formatter.CompactDisplay));
            obj.CreateDataPropertyOrThrow(PropertyKey.SignDisplay, IntlProviderOptions.ToStringValue(formatter.SignDisplay));
            obj.CreateDataPropertyOrThrow(PropertyKey.UseGrouping, formatter.UseGrouping);
            switch (formatter.Style)
            {
            case NumberStyle.Currency:
                obj.CreateDataPropertyOrThrow(PropertyKey.Currency, formatter.Currency);
                obj.CreateDataPropertyOrThrow(PropertyKey.CurrencyDisplay, IntlProviderOptions.ToStringValue(formatter.CurrencyDisplay));
                obj.CreateDataPropertyOrThrow(PropertyKey.CurrencySign, IntlProviderOptions.ToStringValue(formatter.CurrencySign));
                break;

            case NumberStyle.Unit:
                obj.CreateDataPropertyOrThrow(PropertyKey.Unit, formatter.Unit);
                obj.CreateDataPropertyOrThrow(PropertyKey.UnitDisplay, IntlProviderOptions.ToStringValue(formatter.UnitDisplay));
                break;
            }
            if (formatter.Digits.UseSignificantDigits)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumSignificantDigits, formatter.Digits.MinimumSignificantDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MaximumSignificantDigits, formatter.Digits.MaximumSignificantDigits);
            }
            else
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumIntegerDigits, formatter.Digits.MinimumSignificantDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MinimumFractionDigits, formatter.Digits.MinimumFractionDigits);
                obj.CreateDataPropertyOrThrow(PropertyKey.MaximumFractionDigits, formatter.Digits.MaximumFractionDigits);
            }
            return(obj);
        }
예제 #7
0
        public static EcmaValue ResolvedOptions([This] EcmaValue thisValue)
        {
            DateTimeFormat     formatter          = thisValue.GetUnderlyingObject <DateTimeFormat>();
            DateTimePartStyles dateTimePartStyles = formatter.DateTimePartStyles;
            EcmaObject         obj = new EcmaObject();

            obj.CreateDataPropertyOrThrow(PropertyKey.Locale, formatter.Locale);
            obj.CreateDataPropertyOrThrow(PropertyKey.Calendar, formatter.Calendar);
            obj.CreateDataPropertyOrThrow(PropertyKey.TimeZone, formatter.TimeZone);
            obj.CreateDataPropertyOrThrow(PropertyKey.Hour12, formatter.Hour12);
            obj.CreateDataPropertyOrThrow(PropertyKey.HourCycle, IntlProviderOptions.ToStringValue(formatter.HourCycle));
            obj.CreateDataPropertyOrThrow(PropertyKey.FormatMatcher, IntlProviderOptions.ToStringValue(formatter.FormatMatcher));
            if (dateTimePartStyles.Weekday != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Weekday, IntlProviderOptions.ToStringValue(dateTimePartStyles.Weekday));
            }
            if (dateTimePartStyles.Era != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Era, IntlProviderOptions.ToStringValue(dateTimePartStyles.Era));
            }
            if (dateTimePartStyles.Year != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Year, IntlProviderOptions.ToStringValue(dateTimePartStyles.Year));
            }
            if (dateTimePartStyles.Month != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Month, IntlProviderOptions.ToStringValue(dateTimePartStyles.Month));
            }
            if (dateTimePartStyles.Day != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Day, IntlProviderOptions.ToStringValue(dateTimePartStyles.Day));
            }
            if (dateTimePartStyles.Hour != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Hour, IntlProviderOptions.ToStringValue(dateTimePartStyles.Hour));
            }
            if (dateTimePartStyles.Minute != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Minute, IntlProviderOptions.ToStringValue(dateTimePartStyles.Minute));
            }
            if (dateTimePartStyles.Second != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.Second, IntlProviderOptions.ToStringValue(dateTimePartStyles.Second));
            }
            if (dateTimePartStyles.TimeZoneName != default)
            {
                obj.CreateDataPropertyOrThrow(PropertyKey.TimeZoneName, IntlProviderOptions.ToStringValue(dateTimePartStyles.TimeZoneName));
            }
            return(obj);
        }