Example #1
0
 /// <summary>
 /// Ensures that the value of a parameter is null, or infinite, or greater than or equal to zero.
 /// </summary>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="paramName">The name of the parameter.</param>
 /// <returns>The value of the parameter.</returns>
 public static TimeSpan?IsNullOrInfiniteOrGreaterThanOrEqualToZero(TimeSpan?value, string paramName)
 {
     if (value.HasValue && value.Value < TimeSpan.Zero && value.Value != Timeout.InfiniteTimeSpan)
     {
         var message = string.Format("Value is not null or infinite or greater than or equal to zero: {0}.", TimeSpanParser.ToString(value.Value));
         throw new ArgumentOutOfRangeException(paramName, message);
     }
     return(value);
 }
Example #2
0
 /// <summary>
 /// Ensures that the value of a parameter is greater than or equal to zero.
 /// </summary>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="paramName">The name of the parameter.</param>
 /// <returns>The value of the parameter.</returns>
 public static TimeSpan IsGreaterThanOrEqualToZero(TimeSpan value, string paramName)
 {
     if (value < TimeSpan.Zero)
     {
         var message = string.Format("Value is not greater than or equal to zero: {0}.", TimeSpanParser.ToString(value));
         throw new ArgumentOutOfRangeException(paramName, message);
     }
     return(value);
 }