/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="style"></param> /// <param name="formatProvider"></param> /// <param name="byteAct"></param> /// <returns></returns> public static bool Is(string str, NumberStyles style = NumberStyles.Integer, IFormatProvider formatProvider = null, Action <sbyte> byteAct = null) { if (string.IsNullOrWhiteSpace(str)) { return(false); } var result = sbyte.TryParse(str, style, formatProvider.SafeNumber(), out var number); if (!result) { result = ValueDeterminer.IsXxxAgain <sbyte>(str); } if (result) { byteAct?.Invoke(number); } return(result); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="style"></param> /// <param name="formatProvider"></param> /// <param name="dtAct"></param> /// <returns></returns> public static bool Is(string str, DateTimeStyles style = DateTimeStyles.None, IFormatProvider formatProvider = null, Action <DateTimeOffset> dtAct = null) { if (string.IsNullOrWhiteSpace(str)) { return(false); } var result = DateTimeOffset.TryParse(str, formatProvider.SafeDateTime(), style, out var dateTimeOffset); if (!result) { result = ValueDeterminer.IsXxxAgain <DateTimeOffset>(str); } if (result) { dtAct?.Invoke(dateTimeOffset); } return(result); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="guidAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, Guid> > tries, Action <Guid> guidAct = null) => ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, Is, tries, guidAct);
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="style"></param> /// <param name="formatProvider"></param> /// <param name="floatAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, float> > tries, NumberStyles style = NUMBER_STYLES, IFormatProvider formatProvider = null, Action <float> floatAct = null) { return(ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, (s, act) => Is(s, style, formatProvider.SafeNumber(), act), tries, floatAct)); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="ignoreCase"></param> /// <param name="enumAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, TEnum> > tries, bool ignoreCase = false, Action <TEnum> enumAct = null) => ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, (s, act) => Is(s, ignoreCase, act), tries, enumAct);
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="encodingAction"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, Encoding> > tries, Action <Encoding> encodingAction = null) { return(ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, Is, tries, encodingAction)); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="style"></param> /// <param name="formatProvider"></param> /// <param name="byteAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, sbyte> > tries, NumberStyles style = NumberStyles.Integer, IFormatProvider formatProvider = null, Action <sbyte> byteAct = null) { return(ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, (s, act) => Is(s, style, formatProvider.SafeNumber(), act), tries, byteAct)); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="addressAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, IPAddress> > tries, Action <IPAddress> addressAct = null) => ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, Is, tries, addressAct);
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="tries"></param> /// <param name="formatProvider"></param> /// <param name="dtAct"></param> /// <returns></returns> public static bool Is(string str, IEnumerable <IConversionTry <string, TimeSpan> > tries, IFormatProvider formatProvider = null, Action <TimeSpan> dtAct = null) { return(ValueDeterminer.IsXXX(str, string.IsNullOrWhiteSpace, (s, act) => Is(s, formatProvider, act), tries, dtAct)); }