mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-10-01 07:55:22 +02:00
upgraded to autofac 3. created nancy only mode for nzbdrone.exe /n
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user