mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -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
86
NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs
Normal file
86
NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureTypeExtensions
|
||||
{
|
||||
private static class Types
|
||||
{
|
||||
internal static readonly Type IntType = typeof (int);
|
||||
|
||||
internal static readonly Type ShortType = typeof(short);
|
||||
|
||||
internal static readonly Type DecimalType = typeof(decimal);
|
||||
|
||||
internal static readonly Type DoubleType = typeof(double);
|
||||
|
||||
internal static readonly Type FloatType = typeof(float);
|
||||
|
||||
internal static readonly Type BoolType = typeof(bool);
|
||||
|
||||
internal static readonly Type DateTimeType = typeof(DateTime);
|
||||
|
||||
internal static readonly Type StringType = typeof(string);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsInt(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.IntType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsShort(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.ShortType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsDecimal(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.DecimalType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsDouble(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.DoubleType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsFloat(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.FloatType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsBool(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.BoolType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsDateTime(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.DateTimeType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsString(this TypeParam param)
|
||||
{
|
||||
return IsOfType(param, Types.StringType);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static TypeParam IsOfType(this TypeParam param, Type type)
|
||||
{
|
||||
if (!param.Type.Equals(type))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name,
|
||||
ExceptionMessages.EnsureExtensions_IsNotOfType.Inject(param.Type.FullName));
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue