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 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 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 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(object fromObj, object defaultVal, Type xType, out object result) { if (TypeDeterminer.IsStringType(xType)) { result = StrConvX.ObjectSafeToString(fromObj, StrConvX.ObjectSafeToString(defaultVal)); return(true); } if (TypeDeterminer.IsNumericType(xType)) { return(FromObjToNumericType(fromObj, defaultVal, xType, out result)); } if (TypeDeterminer.IsEnumType(xType)) { result = EnumConvX.ObjToEnum(fromObj, xType, defaultVal); } if (TypeDeterminer.IsDateTimeTypes(xType)) { return(FromObjToDateTime(fromObj, defaultVal, xType, out result)); } if (TypeDeterminer.IsGuidType(xType)) { result = GuidConvX.ObjToGuid(fromObj, GuidConvX.ObjToGuid(defaultVal)); return(true); } if (TypeDeterminer.IsOriginObject(xType)) { result = fromObj; return(true); } result = defaultVal; return(false); }