private static bool FromObjToNullableTypeProxy(object fromObj, Type xType, out object result) { var innerType = TypeConv.GetNonNullableType(xType); if (TypeDeterminer.IsStringType(innerType)) { result = StrConvX.ObjectSafeToString(fromObj); return(true); } if (TypeDeterminer.IsNumericType(innerType)) { return(FromObjToNullableNumericType(fromObj, innerType, out result)); } if (TypeDeterminer.IsEnumType(innerType)) { result = EnumConvX.ObjToNullableEnum(fromObj, innerType); } if (TypeDeterminer.IsDateTimeTypes(innerType)) { return(FromObjToNullableDateTimeType(fromObj, innerType, out result)); } if (TypeDeterminer.IsGuidType(innerType)) { result = GuidConvX.ObjToNullableGuid(fromObj); return(true); } if (TypeDeterminer.IsOriginObject(innerType)) { result = fromObj; return(true); } result = null; return(false); }
private static bool FromObjToTypeProxy <X>(object fromObj, X defaultVal, Type xType, out object result) { if (TypeDeterminer.IsStringType(defaultVal, out var defaultStr)) { result = StrConvX.ObjectSafeToString(fromObj, defaultStr); return(true); } if (TypeDeterminer.IsNumericType(xType)) { return(FromObjToNumericType(fromObj, defaultVal, xType, out result)); } if (TypeDeterminer.IsEnumType(xType)) { result = EnumConvX.ObjToEnum(fromObj, xType, defaultVal); return(true); } if (TypeDeterminer.IsDateTimeTypes(xType)) { return(FromObjToDateTime(fromObj, defaultVal, xType, out result)); } if (defaultVal is Guid defaultGuid) { result = GuidConvX.ObjToGuid(fromObj, defaultGuid); return(true); } if (TypeDeterminer.IsOriginObject(xType)) { result = defaultVal; return(true); } result = defaultVal; return(false); }