Exemplo n.º 1
0
 public static ArgumentUtilitiesHandle <decimal?> EnsureBetween(this ArgumentUtilitiesHandle <decimal?> hnd, decimal bound1Inclusive, decimal bound2Inclusive)
 {
     if (!hnd.Value.HasValue || NumberUtilities.Between(number: hnd.Value.Value, a: bound1Inclusive, b: bound2Inclusive))
     {
         return(hnd);
     }
     else
     {
         var exceptionMessage = $"{(hnd.IsProp ? $"Указано недопустимое значение свойства '{hnd.Name}'.{Environment.NewLine}" : string.Empty)}{FormatXResource(typeof(ArgumentOutOfRangeException), "OutOfRange/WithRange", (bound1Inclusive > bound2Inclusive ? bound2Inclusive : bound1Inclusive).ToString("g"), (bound2Inclusive > bound1Inclusive ? bound2Inclusive : bound1Inclusive).ToString("g"))}";
         throw
             hnd.ExceptionFactory?.Invoke(message: exceptionMessage)
             ?? new ArgumentOutOfRangeException(paramName: hnd.Name, message: exceptionMessage);
     }
 }
Exemplo n.º 2
0
 public static bool TryParse(this string value, IFormatProvider formatProvider, out int?result)
 => NumberUtilities.TryParse(value, formatProvider, out result);
Exemplo n.º 3
0
 public static bool TryParse(this string value, out int?result)
 => NumberUtilities.TryParse(value, out result);
Exemplo n.º 4
0
 public static bool TryParseInvariant(this string value, out long?result)
 => NumberUtilities.TryParseInvariant(value, out result);