/// <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) { return(value); } var message = $"Value is not null or infinite or greater than or equal to zero: {TimeSpanParser.ToString(value.Value)}."; throw new ArgumentOutOfRangeException(paramName, message); }