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

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

            default:
                return(sourceObj.AsBigInteger());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Casts the object to the System.Decimal
        /// </summary>
        /// <param name="sourceObj">The source object</param>
        public static decimal?CastNullableDecimal(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                return(null);

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

            default:
                return(sourceObj.AsDecimal());
            }
        }
Exemplo n.º 3
0
        public static decimal CastDecimal(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

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

            default:
                return(sourceObj.AsDecimal());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Casts the object to the System.Single
        /// </summary>
        /// <param name="sourceObj">The source object</param>
        public static float?CastNullableSingle(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                return(null);

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

            default:
                return(sourceObj.AsFloat());
            }
        }
Exemplo n.º 5
0
        public static float CastSingle(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

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

            default:
                return(sourceObj.AsFloat());
            }
        }
Exemplo n.º 6
0
        public static ulong CastUInt64(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

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

            default:
                return(sourceObj.AsUInt64());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Casts the object to the System.UInt64
        /// </summary>
        /// <param name="sourceObj">The source object</param>
        public static ulong?CastNullableUInt64(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                return(null);

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

            default:
                return(sourceObj.AsUInt64());
            }
        }
Exemplo n.º 8
0
        public static int CastInt32(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

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

            default:
                return(sourceObj.AsInt32());
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Casts the object to the System.Int32
        /// </summary>
        /// <param name="sourceObj">The source object</param>
        public static int?CastNullableInt32(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                return(null);

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

            default:
                return(sourceObj.AsInt32());
            }
        }
Exemplo n.º 10
0
        public static byte CastByte(object sourceObj)
        {
            switch (sourceObj)
            {
            case null:
                throw new ArgumentException();

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

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