public static bool FromObjToNumericType <N>(object fromObj, N defaultVal, Type xType, out object result) { var valueUpdated = true; result = defaultVal; if (xType == TypeClass.ByteClazz) { result = NumConvX.ObjectToByte(fromObj, NumConvX.ObjectToByte(defaultVal)); } else if (xType == TypeClass.SByteClazz) { result = NumConvX.ObjectToSByte(fromObj, NumConvX.ObjectToSByte(defaultVal)); } else if (xType == TypeClass.Int16Clazz) { result = NumConvX.ObjectToInt16(fromObj, NumConvX.ObjectToInt16(defaultVal)); } else if (xType == TypeClass.UInt16Clazz) { result = NumConvX.ObjectToUInt16(fromObj, NumConvX.ObjectToUInt16(defaultVal)); } else if (xType == TypeClass.Int32Clazz) { result = NumConvX.ObjectToInt32(fromObj, NumConvX.ObjectToInt32(defaultVal)); } else if (xType == TypeClass.UInt32Clazz) { result = NumConvX.ObjectToUInt32(fromObj, NumConvX.ObjectToUInt32(defaultVal)); } else if (xType == TypeClass.Int64Clazz) { result = NumConvX.ObjectToInt64(fromObj, NumConvX.ObjectToInt64(defaultVal)); } else if (xType == TypeClass.UInt64Clazz) { result = NumConvX.ObjectToUInt64(fromObj, NumConvX.ObjectToUInt64(defaultVal)); } else if (xType == TypeClass.FloatClazz) { result = NumConvX.ObjectToFloat(fromObj, NumConvX.ObjectToFloat(defaultVal)); } else if (xType == TypeClass.DoubleClazz) { result = NumConvX.ObjectToDouble(fromObj, NumConvX.ObjectToDouble(defaultVal)); } else if (xType == TypeClass.DecimalClazz) { result = NumConvX.ObjectToDecimal(fromObj, NumConvX.ObjectToDecimal(defaultVal)); } else { valueUpdated = false; } return(valueUpdated); }
private static bool FromEnumToNumericType <N>(Type enumType, object enumVal, N defaultVal, Type xType, out object result) { var valueUpdated = true; result = defaultVal; if (xType == TypeClass.ByteClazz) { result = NumConvX.EnumToByte(enumType, enumVal, NumConvX.ObjectToByte(defaultVal)); } else if (xType == TypeClass.SByteClazz) { result = NumConvX.EnumToSByte(enumType, enumVal, NumConvX.ObjectToSByte(defaultVal)); } else if (xType == TypeClass.Int16Clazz) { result = NumConvX.EnumToInt16(enumType, enumVal, NumConvX.ObjectToInt16(defaultVal)); } else if (xType == TypeClass.UInt16Clazz) { result = NumConvX.EnumToUInt16(enumType, enumVal, NumConvX.ObjectToUInt16(defaultVal)); } else if (xType == TypeClass.Int32Clazz) { result = NumConvX.EnumToInt32(enumType, enumVal, NumConvX.ObjectToInt32(defaultVal)); } else if (xType == TypeClass.UInt32Clazz) { result = NumConvX.EnumToUInt32(enumType, enumVal, NumConvX.ObjectToUInt32(defaultVal)); } else if (xType == TypeClass.Int64Clazz) { result = NumConvX.EnumToInt64(enumType, enumVal, NumConvX.ObjectToInt64(defaultVal)); } else if (xType == TypeClass.UInt32Clazz) { result = NumConvX.EnumToUInt64(enumType, enumVal, NumConvX.ObjectToUInt64(defaultVal)); } else { valueUpdated = false; } return(valueUpdated); }