private static bool FromObjToNullableNumericType(object fromObj, Type innerType, out object result)
        {
            var valueUpdated = true;

            result = null;

            if (innerType == TypeClass.ByteClass)
            {
                result = NumericConv.ObjectToNullableByte(fromObj);
            }
            else if (innerType == TypeClass.SByteClass)
            {
                result = NumericConv.ObjectToNullableSByte(fromObj);
            }
            else if (innerType == TypeClass.Int16Class)
            {
                result = NumericConv.ObjectToNullableInt16(fromObj);
            }
            else if (innerType == TypeClass.UInt16Class)
            {
                result = NumericConv.ObjectToNullableInt16(fromObj);
            }
            else if (innerType == TypeClass.Int32Class)
            {
                result = NumericConv.ObjectToNullableInt32(fromObj);
            }
            else if (innerType == TypeClass.UInt32Class)
            {
                result = NumericConv.ObjectToNullableUInt32(fromObj);
            }
            else if (innerType == TypeClass.Int64Class)
            {
                result = NumericConv.ObjectToNullableInt64(fromObj);
            }
            else if (innerType == TypeClass.UInt64Class)
            {
                result = NumericConv.ObjectToNullableUInt64(fromObj);
            }
            else if (innerType == TypeClass.FloatClass)
            {
                result = NumericConv.ObjectToNullableFloat(fromObj);
            }
            else if (innerType == TypeClass.DoubleClass)
            {
                result = NumericConv.ObjectToNullableDouble(fromObj);
            }
            else if (innerType == TypeClass.DecimalClass)
            {
                result = NumericConv.ObjectToNullableDecimal(fromObj);
            }
            else
            {
                valueUpdated = false;
            }

            return(valueUpdated);
        }
Beispiel #2
0
        private static bool FromNullableNumericTypeToString(object numericVal, Type oType, CastingContext context, out object result)
        {
            var valueUpdated = true;

            result = null;

            if (oType == TypeClass.Int16NullableClass)
            {
                result = StringConv.Int16ToString(NumericConv.ObjectToNullableInt16(numericVal), string.Empty);
            }
            else if (oType == TypeClass.UInt16NullableClass)
            {
                result = StringConv.UInt16ToString(NumericConv.ObjectToNullableUInt16(numericVal), string.Empty);
            }
            else if (oType == TypeClass.Int32NullableClass)
            {
                result = StringConv.Int32ToString(NumericConv.ObjectToNullableInt32(numericVal), string.Empty);
            }
            else if (oType == TypeClass.UInt32NullableClass)
            {
                result = StringConv.UInt32ToString(NumericConv.ObjectToNullableUInt32(numericVal), string.Empty);
            }
            else if (oType == TypeClass.Int64NullableClass)
            {
                result = StringConv.Int64ToString(NumericConv.ObjectToNullableInt64(numericVal), string.Empty);
            }
            else if (oType == TypeClass.UInt64NullableClass)
            {
                result = StringConv.UInt64ToString(NumericConv.ObjectToNullableUInt64(numericVal), string.Empty);
            }
            else if (oType == TypeClass.FloatNullableClass)
            {
                result = StringConv.FloatToString(NumericConv.ObjectToNullableFloat(numericVal), context.Digits);
            }
            else if (oType == TypeClass.DoubleNullableClass)
            {
                result = StringConv.DoubleToString(NumericConv.ObjectToNullableDouble(numericVal), context.Digits);
            }
            else if (oType == TypeClass.DecimalNullableClass)
            {
                result = StringConv.DecimalToString(NumericConv.ObjectToNullableDecimal(numericVal), context.Digits, string.Empty);
            }
            else
            {
                valueUpdated = false;
            }

            return(valueUpdated);
        }