Exemplo n.º 1
0
        /// <summary>
        /// Casts the object to the System.Double
        /// </summary>
        /// <param name="sourceObj">The source object</param>
        public static double?CastNullableDouble(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                return(null);

            case string stringValue:
                try {
                    return(SimpleTypeParserFunctions.ParseDouble(stringValue));
                }
                catch (FormatException) {
                    return(default(double?));
                }

            default:
                return(sourceObj.AsDouble());
            }
        }
Exemplo n.º 2
0
        public static double CastDouble(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

            case string stringValue:
                try {
                    return(SimpleTypeParserFunctions.ParseDouble(stringValue));
                }
                catch (FormatException) {
                    return(default(double));
                }


            default:
                return(sourceObj.AsDouble());
            }
        }