private static bool FromStringToTypeProxy(string from, object defaultVal, Type xType, out object result) { if (TypeDeterminer.IsNumericType(xType)) { return(FromStringToNumericType(from, defaultVal, xType, out result)); } if (TypeDeterminer.IsGuidType(xType)) { return(FromStringToGuid(from, defaultVal, out result)); } if (TypeDeterminer.IsDateTimeTypes(xType)) { return(FromStringToDateTimeType(from, defaultVal, xType, out result)); } if (TypeDeterminer.IsEnumType(xType)) { return(FromStringToEnum(from, xType, defaultVal, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = from; return(true); } var _ = TypeDeterminer.GetDefaultValue(xType); result = from.Is(xType, t => _ = t) ? _ : defaultVal; return(false); }
private static bool FromStringToTypeProxy <X>(string from, X defaultVal, Type xType, out object result) { if (TypeDeterminer.IsNumericType(xType)) { return(FromStringToNumericType(from, defaultVal, xType, out result)); } if (TypeDeterminer.IsGuidType(xType)) { return(FromStringToGuid(from, defaultVal, out result)); } if (TypeDeterminer.IsDateTimeTypes(xType)) { return(FromStringToDateTimeType(from, defaultVal, xType, out result)); } if (TypeDeterminer.IsEnumType(xType)) { return(FromStringToEnum(from, defaultVal, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = defaultVal; return(true); } object _ = default(X); result = from.Is(typeof(X), t => _ = t) ? _ : defaultVal; return(false); }
private static bool FromStringToNullableTypeProxy(string from, Type xType, out object result) { var innerType = TypeConv.GetNonNullableType(xType); if (TypeDeterminer.IsNumericType(innerType)) { return(FromStringToNullableNumericType(from, innerType, out result)); } if (TypeDeterminer.IsGuidType(innerType)) { return(FromStringToNullableGuid(from, out result)); } if (TypeDeterminer.IsDateTimeTypes(innerType)) { return(FromStringToNullableDateTimeType(from, innerType, out result)); } if (TypeDeterminer.IsEnumType(xType)) { return(FromStringToNullableEnum(from, innerType, out result)); } if (TypeDeterminer.IsOriginObject(innerType)) { result = from; return(true); } var _ = TypeDeterminer.GetDefaultValue(xType); result = from.Is(xType, t => _ = t) ? _ : null; return(false); }
private static bool FromGuidToTypeProxy(Guid from, object defaultVal, CastingContext context, Type xType, out object result) { if (defaultVal is string defaultStr) { return(FromGuidToString(from, context, defaultStr, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = from; return(true); } result = defaultVal; return(false); }
private static bool FromGuidToNullableTypeProxy(Guid from, CastingContext context, Type xType, out object result) { var innerType = TypeConv.GetNonNullableType(xType); if (innerType == TypeClass.StringClazz) { return(FromGuidToString(from, context, string.Empty, out result)); } if (TypeDeterminer.IsOriginObject(innerType)) { result = from; return(true); } result = null; return(false); }
private static bool FromDateTimeToTypeProxy(DateTime dateTime, object defaultVal, CastingContext context, Type xType, out object result) { if (TypeDeterminer.IsStringType(defaultVal, out var givenFormat)) { return(FromDateTimeToString(dateTime, givenFormat, context, out result)); } if (TypeDeterminer.IsNumericType(xType)) { return(FromDateTimeToNumericType(dateTime, defaultVal, xType, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = dateTime; return(true); } result = defaultVal; return(false); }
private static bool FromNumericTypeToTypeProxy <X>(object oVal, X defaultVal, CastingContext context, Type xType, out object result) { if (TypeDeterminer.IsStringType(defaultVal, out var defaultStr)) { return(FromNumericTypeToString(oVal, context, defaultStr, out result)); } if (TypeDeterminer.IsNumericType(xType)) { return(FromNumericTypeToNumericType(oVal, defaultVal, xType, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = oVal; return(true); } result = defaultVal; return(false); }
private static bool FromBooleanToTypeProxy(bool oVal, object defaultVal, CastingContext context, Type xType, out object result) { if (TypeDeterminer.IsStringType(xType)) { return(FromBooleanToString(oVal, context, out result)); } if (TypeDeterminer.IsNumericType(xType)) { return(FromBooleanToNumericType(oVal, context, xType, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = oVal; return(true); } result = defaultVal; return(false); }
private static bool FromEnumToTypeProxy(Type enumType, object enumVal, object defaultVal, CastingContext context, Type xType, out object result) { if (TypeDeterminer.IsStringType(defaultVal, out var defaultStr)) { return(FromEnumToString(enumType, enumVal, defaultStr, out result)); } if (TypeDeterminer.IsNumericType(xType)) { return(FromEnumToNumericType(enumType, enumVal, defaultVal, xType, out result)); } if (TypeDeterminer.IsOriginObject(xType)) { result = enumVal; return(true); } result = defaultVal; return(false); }
private static bool FromDateTimeToNullableTypeProxy(DateTime dateTime, CastingContext context, Type xType, out object result) { var innerType = TypeConv.GetNonNullableType(xType); if (TypeDeterminer.IsStringType(innerType)) { return(FromDateTimeToNullableString(dateTime, context, out result)); } if (TypeDeterminer.IsNumericType(innerType)) { return(FromDateTimeToNullableNumericType(dateTime, innerType, out result)); } if (TypeDeterminer.IsOriginObject(innerType)) { result = dateTime; return(true); } result = null; return(false); }
private static bool FromNullableNumericTypeToTypeProxy(Type oType, object oVal, CastingContext context, Type xType, out object result) { var innerType = TypeConv.GetNonNullableType(xType); if (TypeDeterminer.IsStringType(innerType)) { return(FromNullableNumericTypeToString(oVal, oType, context, out result)); } if (TypeDeterminer.IsNumericType(innerType)) { return(FromNumericTypeToNullableNumericType(oVal, innerType, out result)); } if (TypeDeterminer.IsOriginObject(innerType)) { result = oVal; return(true); } result = null; return(false); }
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); }