public JobStatus(QuantityOfWork total, QuantityOfWork completed, bool busy) { if (total < completed) { throw new ArgumentOutOfRangeException(nameof(total), $"{nameof(total)} < {nameof(completed)}"); } if (total < QuantityOfWork.None) { throw new ArgumentOutOfRangeException(nameof(total), $"{nameof(total)} < {nameof(QuantityOfWork.None)}"); } Total = total ?? throw new ArgumentNullException(nameof(total)); Completed = completed ?? throw new ArgumentNullException(nameof(completed)); Busy = busy; }
public static JobStatus Create(QuantityOfWork total) => new JobStatus(total, QuantityOfWork.None, false);
public static QuantityOfWork ClampOrdered(this QuantityOfWork work, QuantityOfWork lower, QuantityOfWork upper) => work <lower?lower : work> upper ? upper : work;
public static QuantityOfWork Clamp(this QuantityOfWork work, QuantityOfWork first, QuantityOfWork second) => first < second?work.ClampOrdered(first, second) : work.ClampOrdered(second, first);