NumberToBoolean() public static méthode

public static NumberToBoolean ( double value ) : bool
value double
Résultat bool
Exemple #1
0
        public override bool ToBoolean()
        {
            switch (Convert.GetTypeCode(Value))
            {
            case TypeCode.Boolean:
                return((bool)Value);

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

            case TypeCode.DateTime:
                return(JsNumber.NumberToBoolean(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(JsNumber.NumberToBoolean((double)Value));

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

            case TypeCode.DBNull:
            case TypeCode.Empty:
            default:
                if (value is IConvertible)
                {
                    return(Convert.ToBoolean(Value));
                }
                else
                {
                    return(true);
                }
            }
        }
Exemple #2
0
        public override bool ToBoolean()
        {
            if (this.Value != null && !(this.Value is IConvertible))
            {
                return(true);
            }
            switch (Convert.GetTypeCode(this.Value))
            {
            case TypeCode.Object:
                return(Convert.ToBoolean(this.Value));

            case TypeCode.Boolean:
                return((bool)this.Value);

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

            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
                return(JsNumber.NumberToBoolean(Convert.ToDouble(this.Value)));

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

            default:
                return(true);
            }
        }
Exemple #3
0
 public override bool ToBoolean()
 {
     return(JsNumber.NumberToBoolean(this.value));
 }