mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 09:47:39 +00:00
56 lines
No EOL
2 KiB
C#
56 lines
No EOL
2 KiB
C#
using System.Diagnostics;
|
|
using NzbDrone.Common.EnsureThat.Resources;
|
|
|
|
namespace NzbDrone.Common.EnsureThat
|
|
{
|
|
public static class EnsureLongExtensions
|
|
{
|
|
[DebuggerStepThrough]
|
|
public static Param<long> IsLt(this Param<long> param, long limit)
|
|
{
|
|
if (param.Value >= limit)
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
|
|
|
return param;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public static Param<long> IsLte(this Param<long> param, long limit)
|
|
{
|
|
if (!(param.Value <= limit))
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
|
|
|
return param;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public static Param<long> IsGt(this Param<long> param, long limit)
|
|
{
|
|
if (param.Value <= limit)
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
|
|
|
return param;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public static Param<long> IsGte(this Param<long> param, long limit)
|
|
{
|
|
if (!(param.Value >= limit))
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
|
|
|
return param;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public static Param<long> IsInRange(this Param<long> param, long min, long max)
|
|
{
|
|
if (param.Value < min)
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
|
|
|
|
if (param.Value > max)
|
|
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
|
|
|
|
return param;
|
|
}
|
|
}
|
|
} |