mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
upgraded to autofac 3. created nancy only mode for nzbdrone.exe /n
This commit is contained in:
parent
177f88303c
commit
b0940ed8de
77 changed files with 3930 additions and 113 deletions
75
NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs
Normal file
75
NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureDateTimeExtensions
|
||||
{
|
||||
|
||||
private static readonly DateTime _minTime = new DateTime(1960, 1, 1);
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsLt(this Param<DateTime> param, DateTime limit)
|
||||
{
|
||||
if (param.Value >= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsLte(this Param<DateTime> param, DateTime limit)
|
||||
{
|
||||
if (!(param.Value <= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsGt(this Param<DateTime> param, DateTime limit)
|
||||
{
|
||||
if (param.Value <= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsGte(this Param<DateTime> param, DateTime limit)
|
||||
{
|
||||
if (!(param.Value >= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsInRange(this Param<DateTime> param, DateTime min, DateTime 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;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsUtc(this Param<DateTime> param)
|
||||
{
|
||||
if (param.Value.Kind != DateTimeKind.Utc)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, "Excepted time to be in UTC but was [{0}]".Inject(param.Value.Kind));
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<DateTime> IsValid(this Param<DateTime> param)
|
||||
{
|
||||
return IsGt(param, _minTime);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue