parent
177f88303c
commit
b0940ed8de
@ -0,0 +1,171 @@
|
||||
// This software is part of the Autofac IoC container
|
||||
// Copyright © 2012 Autofac Contributors
|
||||
// http://autofac.org
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Async;
|
||||
using Autofac.Features.Metadata;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a filter provider for filter attributes that performs property injection.
|
||||
/// </summary>
|
||||
public class AutofacFilterProvider : FilterAttributeFilterProvider
|
||||
{
|
||||
class FilterContext
|
||||
{
|
||||
public ActionDescriptor ActionDescriptor { get; set; }
|
||||
public ILifetimeScope LifetimeScope { get; set; }
|
||||
public Type ControllerType { get; set; }
|
||||
public List<Filter> Filters { get; set; }
|
||||
}
|
||||
|
||||
internal static string ActionFilterMetadataKey = "AutofacMvcActionFilter";
|
||||
|
||||
internal static string AuthorizationFilterMetadataKey = "AutofacMvcAuthorizationFilter";
|
||||
|
||||
internal static string ExceptionFilterMetadataKey = "AutofacMvcExceptionFilter";
|
||||
|
||||
internal static string ResultFilterMetadataKey = "AutofacMvcResultFilter";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutofacFilterProvider"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The <c>false</c> constructor parameter passed to base here ensures that attribute instances are not cached.
|
||||
/// </remarks>
|
||||
public AutofacFilterProvider() : base(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggregates the filters from all of the filter providers into one collection.
|
||||
/// </summary>
|
||||
/// <param name="controllerContext">The controller context.</param>
|
||||
/// <param name="actionDescriptor">The action descriptor.</param>
|
||||
/// <returns>
|
||||
/// The collection filters from all of the filter providers with properties injected.
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Thrown if <paramref name="controllerContext" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public override IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
|
||||
{
|
||||
if (controllerContext == null)
|
||||
{
|
||||
throw new ArgumentNullException("controllerContext");
|
||||
}
|
||||
var filters = base.GetFilters(controllerContext, actionDescriptor).ToList();
|
||||
var lifetimeScope = AutofacDependencyResolver.Current.RequestLifetimeScope;
|
||||
|
||||
if (lifetimeScope != null)
|
||||
{
|
||||
foreach (var filter in filters)
|
||||
lifetimeScope.InjectProperties(filter.Instance);
|
||||
|
||||
var controllerType = controllerContext.Controller.GetType();
|
||||
|
||||
var filterContext = new FilterContext
|
||||
{
|
||||
ActionDescriptor = actionDescriptor,
|
||||
LifetimeScope = lifetimeScope,
|
||||
ControllerType = controllerType,
|
||||
Filters = filters
|
||||
};
|
||||
|
||||
ResolveControllerScopedFilters(filterContext);
|
||||
|
||||
ResolveActionScopedFilters<ReflectedActionDescriptor>(filterContext, d => d.MethodInfo);
|
||||
ResolveActionScopedFilters<ReflectedAsyncActionDescriptor>(filterContext, d => d.AsyncMethodInfo);
|
||||
}
|
||||
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
static void ResolveControllerScopedFilters(FilterContext filterContext)
|
||||
{
|
||||
ResolveControllerScopedFilter<IActionFilter>(filterContext, ActionFilterMetadataKey);
|
||||
ResolveControllerScopedFilter<IAuthorizationFilter>(filterContext, AuthorizationFilterMetadataKey);
|
||||
ResolveControllerScopedFilter<IExceptionFilter>(filterContext, ExceptionFilterMetadataKey);
|
||||
ResolveControllerScopedFilter<IResultFilter>(filterContext, ResultFilterMetadataKey);
|
||||
}
|
||||
|
||||
static void ResolveControllerScopedFilter<TFilter>(FilterContext filterContext, string metadataKey)
|
||||
where TFilter : class
|
||||
{
|
||||
var actionFilters = filterContext.LifetimeScope.Resolve<IEnumerable<Meta<Lazy<TFilter>>>>();
|
||||
|
||||
foreach (var actionFilter in actionFilters.Where(a => a.Metadata.ContainsKey(metadataKey) && a.Metadata[metadataKey] is FilterMetadata))
|
||||
{
|
||||
var metadata = (FilterMetadata)actionFilter.Metadata[metadataKey];
|
||||
if (metadata.ControllerType != null
|
||||
&& metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType)
|
||||
&& metadata.FilterScope == FilterScope.Controller
|
||||
&& metadata.MethodInfo == null)
|
||||
{
|
||||
var filter = new Filter(actionFilter.Value.Value, FilterScope.Controller, metadata.Order);
|
||||
filterContext.Filters.Add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ResolveActionScopedFilters<T>(FilterContext filterContext, Func<T, MethodInfo> methodSelector)
|
||||
where T : ActionDescriptor
|
||||
{
|
||||
var actionDescriptor = filterContext.ActionDescriptor as T;
|
||||
if (actionDescriptor == null) return;
|
||||
|
||||
var methodInfo = methodSelector(actionDescriptor);
|
||||
|
||||
ResolveActionScopedFilter<IActionFilter>(filterContext, methodInfo, ActionFilterMetadataKey);
|
||||
ResolveActionScopedFilter<IAuthorizationFilter>(filterContext, methodInfo, AuthorizationFilterMetadataKey);
|
||||
ResolveActionScopedFilter<IExceptionFilter>(filterContext, methodInfo, ExceptionFilterMetadataKey);
|
||||
ResolveActionScopedFilter<IResultFilter>(filterContext, methodInfo, ResultFilterMetadataKey);
|
||||
}
|
||||
|
||||
static void ResolveActionScopedFilter<TFilter>(FilterContext filterContext, MethodInfo methodInfo, string metadataKey)
|
||||
where TFilter : class
|
||||
{
|
||||
var actionFilters = filterContext.LifetimeScope.Resolve<IEnumerable<Meta<Lazy<TFilter>>>>();
|
||||
|
||||
foreach (var actionFilter in actionFilters.Where(a => a.Metadata.ContainsKey(metadataKey) && a.Metadata[metadataKey] is FilterMetadata))
|
||||
{
|
||||
var metadata = (FilterMetadata)actionFilter.Metadata[metadataKey];
|
||||
if (metadata.ControllerType != null
|
||||
&& metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType)
|
||||
&& metadata.FilterScope == FilterScope.Action
|
||||
&& metadata.MethodInfo.GetBaseDefinition() == methodInfo.GetBaseDefinition())
|
||||
{
|
||||
var filter = new Filter(actionFilter.Value.Value, FilterScope.Action, metadata.Order);
|
||||
filterContext.Filters.Add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// This software is part of the Autofac IoC container
|
||||
// Copyright © 2011 Autofac Contributors
|
||||
// http://autofac.org
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Autofac.Features.Metadata;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Autofac implementation of the <see cref="IModelBinderProvider"/> interface.
|
||||
/// </summary>
|
||||
public class AutofacModelBinderProvider : IModelBinderProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata key for the supported model types.
|
||||
/// </summary>
|
||||
internal static readonly string MetadataKey = "SupportedModelTypes";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the model binder associated with the provided model type.
|
||||
/// </summary>
|
||||
/// <param name="modelType">Type of the model.</param>
|
||||
/// <returns>An <see cref="IModelBinder"/> instance if found; otherwise, <c>null</c>.</returns>
|
||||
public IModelBinder GetBinder(Type modelType)
|
||||
{
|
||||
var modelBinders = DependencyResolver.Current.GetServices<Meta<Lazy<IModelBinder>>>();
|
||||
|
||||
var modelBinder = modelBinders
|
||||
.Where(binder => binder.Metadata.ContainsKey(MetadataKey))
|
||||
.FirstOrDefault(binder => ((List<Type>)binder.Metadata[MetadataKey]).Contains(modelType));
|
||||
return (modelBinder != null) ? modelBinder.Value.Value : null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="InvalidActionExpress" xml:space="preserve">
|
||||
<value>The action method Expression is invalid. It should consist only of a Method call to a controller action method.</value>
|
||||
</data>
|
||||
<data name="InvalidModelBinderType" xml:space="preserve">
|
||||
<value>Type list may not be empty or contain all null values.</value>
|
||||
</data>
|
||||
<data name="MustBeAssignableToFilterType" xml:space="preserve">
|
||||
<value>The type '{0}' must be assignable to the filter type '{1}'.</value>
|
||||
</data>
|
||||
</root>
|
@ -0,0 +1,79 @@
|
||||
// This software is part of the Autofac IoC container
|
||||
// Copyright © 2011 Autofac Contributors
|
||||
// http://autofac.org
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IHttpModule"/> and <see cref="ILifetimeScopeProvider"/> implementation
|
||||
/// that creates a nested lifetime scope for each HTTP request.
|
||||
/// </summary>
|
||||
internal class RequestLifetimeHttpModule : IHttpModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the lifetime scope provider that should be notified when a HTTP request ends.
|
||||
/// </summary>
|
||||
internal static ILifetimeScopeProvider LifetimeScopeProvider { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a module and prepares it to handle requests.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="T:System.Web.HttpApplication"/> that provides access to the
|
||||
/// methods, properties, and events common to all application objects within an ASP.NET application</param>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Thrown if <paramref name="context" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException("context");
|
||||
}
|
||||
context.EndRequest += OnEndRequest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes of the resources (other than memory) used by the module that implements <see cref="T:System.Web.IHttpModule"/>.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetLifetimeScopeProvider(ILifetimeScopeProvider lifetimeScopeProvider)
|
||||
{
|
||||
if (lifetimeScopeProvider == null) throw new ArgumentNullException("lifetimeScopeProvider");
|
||||
|
||||
LifetimeScopeProvider = lifetimeScopeProvider;
|
||||
}
|
||||
|
||||
static void OnEndRequest(object sender, EventArgs e)
|
||||
{
|
||||
if (LifetimeScopeProvider != null)
|
||||
LifetimeScopeProvider.EndLifetimeScope();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="HttpContextNotAvailable" xml:space="preserve">
|
||||
<value>The request lifetime scope cannot be created because the HttpContext is not available.</value>
|
||||
</data>
|
||||
<data name="NullLifetimeScopeReturned" xml:space="preserve">
|
||||
<value>The 'GetLifetimeScopeCore' method implementation on '{0}' returned a null ILifetimeScope instance. When overridden this method must return a valid ILifetimeScope instance for the current HTTP request.</value>
|
||||
</data>
|
||||
</root>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
|
||||
</packages>
|
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="AutoMapper" version="2.2.0" targetFramework="net40" />
|
||||
<package id="FluentValidation" version="3.4.6.0" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy.Bootstrappers.Autofac" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy.Hosting.Aspnet" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Nancy.Hosting.Aspnet" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" targetFramework="net40" />
|
||||
</packages>
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class Ensure
|
||||
{
|
||||
public static Param<T> That<T>(T value, string name = Param.DefaultName)
|
||||
{
|
||||
return new Param<T>(name, value);
|
||||
}
|
||||
|
||||
public static Param<T> That<T>(Expression<Func<T>> expression)
|
||||
{
|
||||
var memberExpression = expression.GetRightMostMember();
|
||||
|
||||
return new Param<T>(
|
||||
memberExpression.ToPath(),
|
||||
expression.Compile().Invoke());
|
||||
}
|
||||
|
||||
public static TypeParam ThatTypeFor<T>(T value, string name = Param.DefaultName)
|
||||
{
|
||||
return new TypeParam(name, value.GetType());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureBoolExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<bool> IsTrue(this Param<bool> param)
|
||||
{
|
||||
if (!param.Value)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotTrue);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<bool> IsFalse(this Param<bool> param)
|
||||
{
|
||||
if (param.Value)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotFalse);
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureCollectionExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<T> HasItems<T>(this Param<T> param) where T : class, ICollection
|
||||
{
|
||||
if (param.Value == null || param.Value.Count < 1)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<Collection<T>> HasItems<T>(this Param<Collection<T>> param)
|
||||
{
|
||||
if (param.Value == null || param.Value.Count < 1)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<IEnumerable<T>> HasItems<T>(this Param<IEnumerable<T>> param)
|
||||
{
|
||||
if (param.Value == null || !param.Value.Any())
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<T[]> HasItems<T>(this Param<T[]> param)
|
||||
{
|
||||
if (param.Value == null || param.Value.Length < 1)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<List<T>> HasItems<T>(this Param<List<T>> param)
|
||||
{
|
||||
if (param.Value == null || param.Value.Count < 1)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<IDictionary<TKey, TValue>> HasItems<TKey, TValue>(this Param<IDictionary<TKey, TValue>> param)
|
||||
{
|
||||
if (param.Value == null || param.Value.Count < 1)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureDecimalExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<decimal> IsLt(this Param<decimal> param, decimal limit)
|
||||
{
|
||||
if (param.Value >= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<decimal> IsLte(this Param<decimal> param, decimal limit)
|
||||
{
|
||||
if (!(param.Value <= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<decimal> IsGt(this Param<decimal> param, decimal limit)
|
||||
{
|
||||
if (param.Value <= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<decimal> IsGte(this Param<decimal> param, decimal limit)
|
||||
{
|
||||
if (!(param.Value >= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<decimal> IsInRange(this Param<decimal> param, decimal min, decimal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureDoubleExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<double> IsLt(this Param<double> param, double limit)
|
||||
{
|
||||
if (param.Value >= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<double> IsLte(this Param<double> param, double limit)
|
||||
{
|
||||
if (!(param.Value <= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<double> IsGt(this Param<double> param, double limit)
|
||||
{
|
||||
if (param.Value <= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<double> IsGte(this Param<double> param, double limit)
|
||||
{
|
||||
if (!(param.Value >= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<double> IsInRange(this Param<double> param, double min, double 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureGuidExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<Guid> IsNotEmpty(this Param<Guid> param)
|
||||
{
|
||||
if (Guid.Empty.Equals(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyGuid);
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureIntExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsLessThan(this Param<int> param, int limit)
|
||||
{
|
||||
if (param.Value >= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsLessThanOrEqualTo(this Param<int> param, int limit)
|
||||
{
|
||||
if (!(param.Value <= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsGreaterThan(this Param<int> param, int limit)
|
||||
{
|
||||
if (param.Value <= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsGreaterOrEqualTo(this Param<int> param, int limit)
|
||||
{
|
||||
if (!(param.Value >= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsInRange(this Param<int> param, int min, int 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureNullableValueTypeExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<T?> IsNotNull<T>(this Param<T?> param) where T : struct
|
||||
{
|
||||
if (param.Value == null || !param.Value.HasValue)
|
||||
throw ExceptionFactory.CreateForParamNullValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNull);
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureObjectExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<T> IsNotNull<T>(this Param<T> param) where T : class
|
||||
{
|
||||
if (param.Value == null)
|
||||
throw ExceptionFactory.CreateForParamNullValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNull);
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
using System.Diagnostics;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public static class EnsureShortExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<short> IsLt(this Param<short> param, short limit)
|
||||
{
|
||||
if (param.Value >= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<short> IsLte(this Param<short> param, short limit)
|
||||
{
|
||||
if (!(param.Value <= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<short> IsGt(this Param<short> param, short limit)
|
||||
{
|
||||
if (param.Value <= limit)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<short> IsGte(this Param<short> param, short limit)
|
||||
{
|
||||
if (!(param.Value >= limit))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<short> IsInRange(this Param<short> param, short min, short 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.EnsureThat.Resources;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static class EnsureStringExtensions
|
||||
{
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> IsNotNullOrWhiteSpace(this Param<string> param)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrWhiteSpace);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> IsNotNullOrEmpty(this Param<string> param)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> HasLengthBetween(this Param<string> param, int minLength, int maxLength)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
|
||||
|
||||
var length = param.Value.Length;
|
||||
|
||||
if (length < minLength)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToShort.Inject(minLength, maxLength, length));
|
||||
|
||||
if (length > maxLength)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLong.Inject(minLength, maxLength, length));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> IsLongerThan(this Param<string> param, int minLength)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
|
||||
|
||||
var length = param.Value.Length;
|
||||
|
||||
if (length < minLength)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, "The string is not long enough. Must be at least '{0}' but was '{1}' characters long.".Inject(minLength, length));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> Matches(this Param<string> param, string match)
|
||||
{
|
||||
return Matches(param, new Regex(match));
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> Matches(this Param<string> param, Regex match)
|
||||
{
|
||||
if (!match.IsMatch(param.Value))
|
||||
{
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_NoMatch.Inject(param.Value, match));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<string> IsRelativePath(this Param<string> param)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(param.Value))
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrWhiteSpace);
|
||||
|
||||
if (!param.Value.EndsWith("\\"))
|
||||
{
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, string.Format("value [{0}] is not a valid relative path. relative paths must end with \\", param.Value));
|
||||
}
|
||||
|
||||
if (param.Value.Length > 1 && param.Value.StartsWith("\\"))
|
||||
{
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, string.Format("value [{0}] is not a valid relative path. relative paths can not start with \\", param.Value));
|
||||
}
|
||||
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public abstract class Param
|
||||
{
|
||||
public const string DefaultName = "";
|
||||
|
||||
public readonly string Name;
|
||||
|
||||
protected Param(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public class Param<T> : Param
|
||||
{
|
||||
public readonly T Value;
|
||||
|
||||
internal Param(string name, T value) : base(name)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="EnsureExtensions_IsNotGte" xml:space="preserve">
|
||||
<value>value '{0}' is not greater than or equal to limit '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotGt" xml:space="preserve">
|
||||
<value>value '{0}' is not greater than limit '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotInRange_ToHigh" xml:space="preserve">
|
||||
<value>value '{0}' is > max '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotInRange_ToLow" xml:space="preserve">
|
||||
<value>value '{0}' is < min '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsEmptyCollection" xml:space="preserve">
|
||||
<value>Empty collection is not allowed.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsEmptyGuid" xml:space="preserve">
|
||||
<value>Empty Guid is not allowed.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotNull" xml:space="preserve">
|
||||
<value>Value can not be null.</value>
|
||||
</data>
|
||||
<data name="ExpressionUtils_GetRightMostMember_NoMemberFound" xml:space="preserve">
|
||||
<value>No MemberExpression found in expression: '{0}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotNullOrWhiteSpace" xml:space="preserve">
|
||||
<value>The string can't be left empty, null or consist of only whitespaces.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotFalse" xml:space="preserve">
|
||||
<value>Expected an expression that evaluates to false.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotTrue" xml:space="preserve">
|
||||
<value>Expected an expression that evaluates to true.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotOfType" xml:space="preserve">
|
||||
<value>The param is not of expected type: '{0}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotLt" xml:space="preserve">
|
||||
<value>value '{0}' is not lower than limit '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotLte" xml:space="preserve">
|
||||
<value>value '{0}' is not lower than or equal to limit '{1}'.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotNullOrEmpty" xml:space="preserve">
|
||||
<value>The string can't be null or empty.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotInRange_ToLong" xml:space="preserve">
|
||||
<value>The string is too long. Must be between '{0}' and '{1}'. Must be between '{0}' and '{1}' but was '{2}' characters long.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_IsNotInRange_ToShort" xml:space="preserve">
|
||||
<value>The string is not long enough. Must be between '{0}' and '{1}' but was '{2}' characters long.</value>
|
||||
</data>
|
||||
<data name="EnsureExtensions_NoMatch" xml:space="preserve">
|
||||
<value>value '{0}' does not match '{1}'</value>
|
||||
</data>
|
||||
</root>
|
@ -0,0 +1,15 @@
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
internal static class StringExtensions
|
||||
{
|
||||
internal static string Inject(this string format, params object[] formattingArgs)
|
||||
{
|
||||
return string.Format(format, formattingArgs);
|
||||
}
|
||||
|
||||
internal static string Inject(this string format, params string[] formattingArgs)
|
||||
{
|
||||
return string.Format(format, formattingArgs);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
public class TypeParam : Param
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
internal TypeParam(string name, Type type)
|
||||
: base(name)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="Exceptron.Client" version="1.0.7" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="AutoMapper" version="2.2.0" targetFramework="net40" />
|
||||
<package id="mongocsharpdriver" version="1.7" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy.Bootstrappers.Autofac" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy.Hosting.Aspnet" version="0.15.3" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Nancy.Bootstrappers.Autofac" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Nancy.Hosting.Aspnet" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" targetFramework="net40" />
|
||||
</packages>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
</packages>
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Nancy.Hosting.Self" version="0.16.1" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
</packages>
|
Loading…
Reference in new issue