private static bool FromObjToNullableTypeProxy(object fromObj, Type xType, out object result) { var innerType = Nullable.GetUnderlyingType(xType); if (innerType == TypeClass.StringClass) { result = StringConv.ObjectSafeToString(fromObj); return(true); } if (TypeHelper.IsNumericType(xType)) { return(FromObjToNullableNumericType(fromObj, xType, out result)); } if (TypeHelper.IsEnumType(innerType)) { result = EnumConv.ObjToNullableEnum(fromObj, innerType); } if (TypeHelper.IsDateTimeTypes(innerType)) { return(FromObjToNullableDateTimeType(fromObj, innerType, out result)); } if (TypeHelper.IsGuidType(innerType)) { result = GuidConv.ObjToNullableGuid(fromObj); return(true); } if (innerType == TypeClass.ObjectClass) { result = fromObj; return(true); } result = null; return(false); }
private static bool FromObjToTypeProxy <X>(object fromObj, X defaultVal, Type xType, out object result) { if (defaultVal is string defaultStr) { result = StringConv.ObjectSafeToString(fromObj, defaultStr); return(true); } if (TypeHelper.IsNumericType(xType)) { return(FromObjToNumericType(fromObj, defaultVal, xType, out result)); } if (TypeHelper.IsEnumType(xType)) { result = EnumConv.ObjToEnum(fromObj, xType, defaultVal); return(true); } if (TypeHelper.IsDateTimeTypes(xType)) { return(FromObjToDateTime(fromObj, defaultVal, xType, out result)); } if (defaultVal is Guid defaultGuid) { result = GuidConv.ObjToGuid(fromObj, defaultGuid); return(true); } if (xType == TypeClass.ObjectClass) { result = defaultVal; return(true); } result = defaultVal; return(false); }
private static bool FromStringToNullableEnum(string from, Type enumType, out object result) { result = EnumConv.StringToNullableEnum(from, enumType); return(true); }
private static bool FromStringToEnum <TEnum>(string from, TEnum defaultVal, out object result) { result = EnumConv.StringToEnum(from, typeof(TEnum), defaultVal); return(true); }
private static bool FromStringToEnum(string from, Type enumType, object defaultVal, out object result) { result = EnumConv.StringToEnum(from, enumType, defaultVal); return(true); }