Esempio n. 1
0
        /// <summary>
        /// 15.1.2.4
        /// </summary>
        public JsInstance IsNaN(JsInstance[] arguments)
        {
            if (arguments.Length < 1)
            {
                return(BooleanClass.New(false));
            }

            return(BooleanClass.New(double.NaN.Equals(arguments[0].ToNumber())));
        }
Esempio n. 2
0
        /// <summary>
        /// 15.1.2.5
        /// </summary>
        protected JsInstance isFinite(JsInstance[] arguments)
        {
            if (arguments.Length < 1 || arguments[0] == JsUndefined.Instance)
            {
                return(BooleanClass.False);
            }

            var value = arguments[0];

            return(BooleanClass.New((value != NumberClass["NaN"] &&
                                     value != NumberClass["POSITIVE_INFINITY"] &&
                                     value != NumberClass["NEGATIVE_INFINITY"])
                                    ));
        }
Esempio n. 3
0
        public JsObject Wrap(object value)
        {
            switch (Convert.GetTypeCode(value))
            {
            case TypeCode.Boolean:
                return(BooleanClass.New((bool)value));

            case TypeCode.Char:
            case TypeCode.String:
                return(StringClass.New(Convert.ToString(value)));

            case TypeCode.DateTime:
                return(DateClass.New((DateTime)value));

            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.SByte:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
            case TypeCode.Decimal:
            case TypeCode.Double:
            case TypeCode.Single:
                return(NumberClass.New(Convert.ToDouble(value)));

            case TypeCode.Object:
                return(ObjectClass.New(value));

            case TypeCode.DBNull:
            case TypeCode.Empty:
            default:
                throw new ArgumentNullException("value");
            }
        }