BooleanToNumber() public static method

public static BooleanToNumber ( bool value ) : double
value bool
return double
Esempio n. 1
0
        public override double ToNumber()
        {
            if (this.Value == null)
            {
                return(0.0);
            }
            if (!(this.Value is IConvertible))
            {
                return(double.NaN);
            }
            switch (Convert.GetTypeCode(this.Value))
            {
            case TypeCode.Boolean:
                return(JsBoolean.BooleanToNumber((bool)this.Value));

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToNumber((string)this.Value));

            case TypeCode.DateTime:
                return(JsDate.DateToDouble((DateTime)this.Value));

            default:
                return(Convert.ToDouble(this.Value));
            }
        }
Esempio n. 2
0
        public override double ToNumber()
        {
            if (Value == null)
            {
                return(0);
            }

            switch (Convert.GetTypeCode(Value))
            {
            case TypeCode.Boolean:
                return(JsBoolean.BooleanToNumber((bool)Value));

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToNumber((string)Value));

            case TypeCode.DateTime:
                return(JsDate.DateToDouble((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(Convert.ToDouble(Value));

            case TypeCode.Object:
                return(Convert.ToDouble(Value));

            case TypeCode.DBNull:
            case TypeCode.Empty:
            default:
                if (value is IConvertible)
                {
                    return(Convert.ToDouble(Value));
                }
                else
                {
                    return(double.NaN);
                }
            }
        }
Esempio n. 3
0
 public override double ToNumber()
 {
     return(JsBoolean.BooleanToNumber(this.value));
 }