upgraded to autofac 3. created nancy only mode for nzbdrone.exe /n
This commit is contained in:
parent
177f88303c
commit
b0940ed8de
|
@ -136,3 +136,4 @@ NzbDrone.Web/_backboneApp/.idea/.
|
|||
*.test-cache
|
||||
*.sqo
|
||||
*.userprefs
|
||||
*/test-results/*
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{DD874E64-C7EC-464D-925F-CF4A709EDEEF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Autofac.Integration.Mvc</RootNamespace>
|
||||
<AssemblyName>Autofac.Integration.Mvc</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\Build\Full.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<DocumentationFile>bin\Debug\Autofac.Integration.Mvc.xml</DocumentationFile>
|
||||
<CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\Build\Full.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
<DocumentationFile>bin\Release\Autofac.Integration.Mvc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>..\..\..\Build\SharedKey.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\MVC3\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutofacDependencyResolver.cs" />
|
||||
<Compile Include="AutofacFilterProvider.cs" />
|
||||
<Compile Include="AutofacModelBinderProvider.cs" />
|
||||
<Compile Include="AutofacWebTypesModule.cs" />
|
||||
<Compile Include="FilterMetadata.cs" />
|
||||
<Compile Include="RegistrationExtensionsResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>RegistrationExtensionsResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="RequestLifetimeScopeProvider.cs" />
|
||||
<Compile Include="ExtensibleActionInvoker.cs" />
|
||||
<Compile Include="ILifetimeScopeProvider.cs" />
|
||||
<Compile Include="ModelBinderTypeAttribute.cs" />
|
||||
<Compile Include="PreApplicationStartCode.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RegistrationExtensions.cs" />
|
||||
<Compile Include="RequestLifetimeHttpModule.cs" />
|
||||
<Compile Include="RequestLifetimeScopeProviderResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>RequestLifetimeScopeProviderResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewRegistrationSource.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="RegistrationExtensionsResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>RegistrationExtensionsResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="RequestLifetimeScopeProviderResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>RequestLifetimeScopeProviderResources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,164 @@
|
|||
// 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.Web.Mvc;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Autofac implementation of the <see cref="IDependencyResolver"/> interface.
|
||||
/// </summary>
|
||||
public class AutofacDependencyResolver : IDependencyResolver
|
||||
{
|
||||
readonly ILifetimeScope _container;
|
||||
readonly Action<ContainerBuilder> _configurationAction;
|
||||
ILifetimeScopeProvider _lifetimeScopeProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutofacDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="container">The container that nested lifetime scopes will be create from.</param>
|
||||
public AutofacDependencyResolver(ILifetimeScope container)
|
||||
{
|
||||
if (container == null) throw new ArgumentNullException("container");
|
||||
_container = container;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutofacDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="container">The container that nested lifetime scopes will be create from.</param>
|
||||
/// <param name="configurationAction">Action on a <see cref="ContainerBuilder"/>
|
||||
/// that adds component registations visible only in nested lifetime scopes.</param>
|
||||
public AutofacDependencyResolver(ILifetimeScope container, Action<ContainerBuilder> configurationAction)
|
||||
: this(container)
|
||||
{
|
||||
if (configurationAction == null) throw new ArgumentNullException("configurationAction");
|
||||
_configurationAction = configurationAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutofacDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="container">The container that nested lifetime scopes will be create from.</param>
|
||||
/// <param name="lifetimeScopeProvider">A <see cref="ILifetimeScopeProvider"/> implementation for
|
||||
/// creating new lifetime scopes.</param>
|
||||
public AutofacDependencyResolver(ILifetimeScope container, ILifetimeScopeProvider lifetimeScopeProvider) :
|
||||
this(container)
|
||||
{
|
||||
if (lifetimeScopeProvider == null) throw new ArgumentNullException("lifetimeScopeProvider");
|
||||
_lifetimeScopeProvider = lifetimeScopeProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutofacDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="container">The container that nested lifetime scopes will be create from.</param>
|
||||
/// <param name="lifetimeScopeProvider">A <see cref="ILifetimeScopeProvider"/> implementation for
|
||||
/// creating new lifetime scopes.</param>
|
||||
/// <param name="configurationAction">Action on a <see cref="ContainerBuilder"/>
|
||||
/// that adds component registations visible only in nested lifetime scopes.</param>
|
||||
public AutofacDependencyResolver(ILifetimeScope container, ILifetimeScopeProvider lifetimeScopeProvider, Action<ContainerBuilder> configurationAction)
|
||||
: this(container, lifetimeScopeProvider)
|
||||
{
|
||||
if (configurationAction == null) throw new ArgumentNullException("configurationAction");
|
||||
_configurationAction = configurationAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Autofac implementation of the dependency resolver.
|
||||
/// </summary>
|
||||
public static AutofacDependencyResolver Current
|
||||
{
|
||||
get
|
||||
{
|
||||
// Issue 351: We can't necessarily cast the current dependency resolver
|
||||
// to AutofacDependencyResolver because diagnostic systems like Glimpse
|
||||
// will wrap/proxy the resolver. Instead we need to register the resolver
|
||||
// on the fly with the request lifetime scope and resolve it accordingly.
|
||||
return DependencyResolver.Current.GetService<AutofacDependencyResolver>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lifetime containing components for processing the current HTTP request.
|
||||
/// </summary>
|
||||
public ILifetimeScope RequestLifetimeScope
|
||||
{
|
||||
get
|
||||
{
|
||||
// Issue 351: Register the AutofacDependencyResolver with
|
||||
// the request lifetime scope so the current resolver can
|
||||
// be retrieved without having to cast it directly to
|
||||
// this specific type.
|
||||
Action<ContainerBuilder> composite = builder =>
|
||||
{
|
||||
if (this._configurationAction != null)
|
||||
{
|
||||
this._configurationAction(builder);
|
||||
}
|
||||
builder.RegisterInstance(this).As<AutofacDependencyResolver>();
|
||||
};
|
||||
if (_lifetimeScopeProvider == null)
|
||||
{
|
||||
_lifetimeScopeProvider = new RequestLifetimeScopeProvider(_container);
|
||||
}
|
||||
return _lifetimeScopeProvider.GetLifetimeScope(composite);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application container that was provided to the constructor.
|
||||
/// </summary>
|
||||
public ILifetimeScope ApplicationContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a single instance of a service.
|
||||
/// </summary>
|
||||
/// <param name="serviceType">Type of the service.</param>
|
||||
/// <returns>The single instance if resolved; otherwise, <c>null</c>.</returns>
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return RequestLifetimeScope.ResolveOptional(serviceType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all available instances of a services.
|
||||
/// </summary>
|
||||
/// <param name="serviceType">Type of the service.</param>
|
||||
/// <returns>The list of instances if any were resolved; otherwise, an empty list.</returns>
|
||||
public IEnumerable<object> GetServices(Type serviceType)
|
||||
{
|
||||
var enumerableServiceType = typeof(IEnumerable<>).MakeGenericType(serviceType);
|
||||
var instance = RequestLifetimeScope.Resolve(enumerableServiceType);
|
||||
return (IEnumerable<object>)instance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,178 @@
|
|||
// 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.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Dependency injection module that registers abstractions for common
|
||||
/// web application properties.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This <see cref="Autofac.Module"/> is primarily used during
|
||||
/// application startup (in <c>Global.asax</c>) to register
|
||||
/// mappings from commonly referenced contextual application properties
|
||||
/// to their corresponding abstraction.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The following mappings are made:
|
||||
/// </para>
|
||||
/// <list type="table">
|
||||
/// <listheader>
|
||||
/// <term>Common Construct</term>
|
||||
/// <description>Abstraction</description>
|
||||
/// </listheader>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current</c></term>
|
||||
/// <description><see cref="System.Web.HttpContextBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Application</c></term>
|
||||
/// <description><see cref="System.Web.HttpApplicationStateBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Request</c></term>
|
||||
/// <description><see cref="System.Web.HttpRequestBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Request.Browser</c></term>
|
||||
/// <description><see cref="System.Web.HttpBrowserCapabilitiesBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Request.Files</c></term>
|
||||
/// <description><see cref="System.Web.HttpFileCollectionBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Request.RequestContext</c></term>
|
||||
/// <description><see cref="System.Web.Routing.RequestContext"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Response</c></term>
|
||||
/// <description><see cref="System.Web.HttpResponseBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Response.Cache</c></term>
|
||||
/// <description><see cref="System.Web.HttpCachePolicyBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Server</c></term>
|
||||
/// <description><see cref="System.Web.HttpServerUtilityBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HttpContext.Current.Session</c></term>
|
||||
/// <description><see cref="System.Web.HttpSessionStateBase"/></description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term><c>HostingEnvironment.VirtualPathProvider</c></term>
|
||||
/// <description><see cref="System.Web.Hosting.VirtualPathProvider"/></description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// <para>
|
||||
/// In addition, the <see cref="System.Web.Mvc.UrlHelper"/> type is registered
|
||||
/// for construction based on the current <see cref="System.Web.Routing.RequestContext"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The lifetime for each of these items is one web request.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public class AutofacWebTypesModule : Module
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers web abstractions with dependency injection.
|
||||
/// </summary>
|
||||
/// <param name="builder">
|
||||
/// The <see cref="Autofac.ContainerBuilder"/> in which registration
|
||||
/// should take place.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method registers mappings between common current context-related
|
||||
/// web constructs and their associated abstract counterparts. See
|
||||
/// <see cref="Autofac.Integration.Mvc.AutofacWebTypesModule"/> for the complete
|
||||
/// list of mappings that get registered.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
builder.Register(c => new HttpContextWrapper(HttpContext.Current))
|
||||
.As<HttpContextBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
// HttpContext properties
|
||||
builder.Register(c => c.Resolve<HttpContextBase>().Request)
|
||||
.As<HttpRequestBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpContextBase>().Response)
|
||||
.As<HttpResponseBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpContextBase>().Server)
|
||||
.As<HttpServerUtilityBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpContextBase>().Session)
|
||||
.As<HttpSessionStateBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpContextBase>().Application)
|
||||
.As<HttpApplicationStateBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
// HttpRequest properties
|
||||
builder.Register(c => c.Resolve<HttpRequestBase>().Browser)
|
||||
.As<HttpBrowserCapabilitiesBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpRequestBase>().Files)
|
||||
.As<HttpFileCollectionBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
builder.Register(c => c.Resolve<HttpRequestBase>().RequestContext)
|
||||
.As<RequestContext>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
// HttpResponse properties
|
||||
builder.Register(c => c.Resolve<HttpResponseBase>().Cache)
|
||||
.As<HttpCachePolicyBase>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
// HostingEnvironment properties
|
||||
builder.Register(c => HostingEnvironment.VirtualPathProvider)
|
||||
.As<VirtualPathProvider>()
|
||||
.InstancePerHttpRequest();
|
||||
|
||||
// MVC types
|
||||
builder.Register(c => new UrlHelper(c.Resolve<RequestContext>()))
|
||||
.As<UrlHelper>()
|
||||
.InstancePerHttpRequest();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
// 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.Mvc;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Injects services from the container into the ASP.NET MVC invocation pipeline.
|
||||
/// This is a Async Controller Action Invoker which can be used for both async and non-async scenarios
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Action methods can include parameters that will be resolved from the
|
||||
/// container, along with regular parameters.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public class ExtensibleActionInvoker : System.Web.Mvc.Async.AsyncControllerActionInvoker
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the parameter value.
|
||||
/// </summary>
|
||||
/// <param name="controllerContext">The controller context.</param><param name="parameterDescriptor">The parameter descriptor.</param>
|
||||
/// <returns>
|
||||
/// The parameter value.
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Thrown if <paramref name="parameterDescriptor" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
protected override object GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
|
||||
{
|
||||
if (parameterDescriptor == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameterDescriptor");
|
||||
}
|
||||
|
||||
// Only resolve parameter values if injection is enabled.
|
||||
var context = AutofacDependencyResolver.Current.RequestLifetimeScope;
|
||||
var value = context.ResolveOptional(parameterDescriptor.ParameterType);
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
// Issue #368
|
||||
// If injection is enabled and the value can't be resolved, fall back to
|
||||
// the default behavior. Or if injection isn't enabled, fall back.
|
||||
// Unfortunately we can't do much to pre-determine if model binding will succeed
|
||||
// because model binding "knows" about a lot of stuff like arrays, certain generic
|
||||
// collection types, type converters, and other stuff that may or may not fail.
|
||||
try
|
||||
{
|
||||
value = base.GetParameterValue(controllerContext, parameterDescriptor);
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
// Don't do anything - this means the default model binder couldn't
|
||||
// activate a new instance or figure out some other way to model
|
||||
// bind it.
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
// 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.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata interface for filter registrations.
|
||||
/// </summary>
|
||||
internal class FilterMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of the controller.
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
public Type ControllerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filter scope.
|
||||
/// </summary>
|
||||
[DefaultValue(FilterScope.First)]
|
||||
public FilterScope FilterScope { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the method info.
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
public MethodInfo MethodInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the order in which the filter is applied.
|
||||
/// </summary>
|
||||
[DefaultValue(-1)]
|
||||
public int Order { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementors are able to control the creation of nested lifetime scopes.
|
||||
/// </summary>
|
||||
public interface ILifetimeScopeProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a nested lifetime scope that services can be resolved from.
|
||||
/// </summary>
|
||||
/// <param name="configurationAction">
|
||||
/// A configuration action that will execute during lifetime scope creation.
|
||||
/// </param>
|
||||
/// <returns>A new or existing nested lifetime scope.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
ILifetimeScope GetLifetimeScope(Action<ContainerBuilder> configurationAction);
|
||||
|
||||
/// <summary>
|
||||
/// Ends the current lifetime scope.
|
||||
/// </summary>
|
||||
void EndLifetimeScope();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global, application-wide container.
|
||||
/// </summary>
|
||||
ILifetimeScope ApplicationContainer { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates what types a model binder supports.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class ModelBinderTypeAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the target types.
|
||||
/// </summary>
|
||||
public IEnumerable<Type> TargetTypes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelBinderTypeAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="targetTypes">The target types.</param>
|
||||
public ModelBinderTypeAttribute(params Type[] targetTypes)
|
||||
{
|
||||
if (targetTypes == null) throw new ArgumentNullException("targetTypes");
|
||||
TargetTypes = targetTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelBinderTypeAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="targetType">The target type.</param>
|
||||
public ModelBinderTypeAttribute(Type targetType)
|
||||
{
|
||||
if (targetType == null) throw new ArgumentNullException("targetType");
|
||||
TargetTypes = new Type[] { targetType };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// 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.ComponentModel;
|
||||
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Container class for the ASP.NET application startup method.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class PreApplicationStartCode
|
||||
{
|
||||
private static bool _startWasCalled;
|
||||
|
||||
/// <summary>
|
||||
/// Performs ASP.NET application startup logic early in the pipeline.
|
||||
/// </summary>
|
||||
public static void Start()
|
||||
{
|
||||
// Guard against multiple calls. All Start calls are made on the same thread, so no lock needed here.
|
||||
if (_startWasCalled) return;
|
||||
|
||||
_startWasCalled = true;
|
||||
DynamicModuleUtility.RegisterModule(typeof(RequestLifetimeHttpModule));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Web;
|
||||
using Autofac.Integration.Mvc;
|
||||
|
||||
[assembly: AssemblyTitle("Autofac.Integration.Mvc")]
|
||||
[assembly: AssemblyDescription("Autofac ASP.NET MVC 4 Integration")]
|
||||
[assembly: InternalsVisibleTo("Autofac.Tests.Integration.Mvc, PublicKey=00240000048000009400000006020000002400005253413100040000010001008728425885ef385e049261b18878327dfaaf0d666dea3bd2b0e4f18b33929ad4e5fbc9087e7eda3c1291d2de579206d9b4292456abffbe8be6c7060b36da0c33b883e3878eaf7c89fddf29e6e27d24588e81e86f3a22dd7b1a296b5f06fbfb500bbd7410faa7213ef4e2ce7622aefc03169b0324bcd30ccfe9ac8204e4960be6")]
|
||||
[assembly: PreApplicationStartMethod(typeof(PreApplicationStartCode), "Start")]
|
||||
[assembly: ComVisible(false)]
|
|
@ -0,0 +1,510 @@
|
|||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Core;
|
||||
using Autofac.Features.Scanning;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends <see cref="ContainerBuilder"/> with methods to support ASP.NET MVC.
|
||||
/// </summary>
|
||||
public static class RegistrationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Share one instance of the component within the context of a single
|
||||
/// HTTP request.
|
||||
/// </summary>
|
||||
/// <typeparam name="TLimit">Registration limit type.</typeparam>
|
||||
/// <typeparam name="TStyle">Registration style.</typeparam>
|
||||
/// <typeparam name="TActivatorData">Activator data type.</typeparam>
|
||||
/// <param name="registration">The registration to configure.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<TLimit, TActivatorData, TStyle>
|
||||
InstancePerHttpRequest<TLimit, TActivatorData, TStyle>(
|
||||
this IRegistrationBuilder<TLimit, TActivatorData, TStyle> registration)
|
||||
{
|
||||
if (registration == null) throw new ArgumentNullException("registration");
|
||||
|
||||
return registration.InstancePerMatchingLifetimeScope(RequestLifetimeScopeProvider.HttpRequestTag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register types that implement IController in the provided assemblies.
|
||||
/// </summary>
|
||||
/// <param name="builder">The container builder.</param>
|
||||
/// <param name="controllerAssemblies">Assemblies to scan for controllers.</param>
|
||||
/// <returns>Registration builder allowing the controller components to be customised.</returns>
|
||||
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
|
||||
RegisterControllers(
|
||||
this ContainerBuilder builder,
|
||||
params Assembly[] controllerAssemblies)
|
||||
{
|
||||
return builder.RegisterAssemblyTypes(controllerAssemblies)
|
||||
.Where(t => typeof(IController).IsAssignableFrom(t) &&
|
||||
t.Name.EndsWith("Controller", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inject an IActionInvoker into the controller's ActionInvoker property.
|
||||
/// </summary>
|
||||
/// <typeparam name="TLimit">Limit type.</typeparam>
|
||||
/// <typeparam name="TActivatorData">Activator data.</typeparam>
|
||||
/// <typeparam name="TRegistrationStyle">Registration style.</typeparam>
|
||||
/// <param name="registrationBuilder">The registration builder.</param>
|
||||
/// <returns>A registration builder.</returns>
|
||||
public static IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle>
|
||||
InjectActionInvoker<TLimit, TActivatorData, TRegistrationStyle>(
|
||||
this IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> registrationBuilder)
|
||||
{
|
||||
return registrationBuilder.InjectActionInvoker(new TypedService(typeof(IActionInvoker)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inject an IActionInvoker into the controller's ActionInvoker property.
|
||||
/// </summary>
|
||||
/// <typeparam name="TLimit">Limit type.</typeparam>
|
||||
/// <typeparam name="TActivatorData">Activator data.</typeparam>
|
||||
/// <typeparam name="TRegistrationStyle">Registration style.</typeparam>
|
||||
/// <param name="registrationBuilder">The registration builder.</param>
|
||||
/// <param name="actionInvokerService">Service used to resolve the action invoker.</param>
|
||||
/// <returns>A registration builder.</returns>
|
||||
public static IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle>
|
||||
InjectActionInvoker<TLimit, TActivatorData, TRegistrationStyle>(
|
||||
this IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
|
||||
Service actionInvokerService)
|
||||
{
|
||||
if (registrationBuilder == null) throw new ArgumentNullException("registrationBuilder");
|
||||
if (actionInvokerService == null) throw new ArgumentNullException("actionInvokerService");
|
||||
|
||||
return registrationBuilder.OnActivating(e =>
|
||||
{
|
||||
var controller = e.Instance as Controller;
|
||||
if (controller != null)
|
||||
controller.ActionInvoker = (IActionInvoker)e.Context.ResolveService(actionInvokerService);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the <see cref="AutofacModelBinderProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="builder">The container builder.</param>
|
||||
public static void RegisterModelBinderProvider(this ContainerBuilder builder)
|
||||
{
|
||||
if (builder == null) throw new ArgumentNullException("builder");
|
||||
|
||||
builder.RegisterType<AutofacModelBinderProvider>()
|
||||
.As<IModelBinderProvider>()
|
||||
.SingleInstance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a provided registration to act as an <see cref="System.Web.Mvc.IModelBinder"/>
|
||||
/// for the specified list of types.
|
||||
/// </summary>
|
||||
/// <param name="registration">
|
||||
/// The registration for the type or object instance that will act as
|
||||
/// the model binder.
|
||||
/// </param>
|
||||
/// <param name="types">
|
||||
/// The list of model <see cref="System.Type"/> for which the <paramref name="registration" />
|
||||
/// should be a model binder.
|
||||
/// </param>
|
||||
/// <typeparam name="TLimit">
|
||||
/// Registration limit type.
|
||||
/// </typeparam>
|
||||
/// <typeparam name="TActivatorData">
|
||||
/// Activator data type.
|
||||
/// </typeparam>
|
||||
/// <typeparam name="TRegistrationStyle">
|
||||
/// Registration style.
|
||||
/// </typeparam>
|
||||
/// <returns>
|
||||
/// An Autofac registration that can be modified as needed.
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Thrown if <paramref name="registration" /> or <paramref name="types" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// Thrown if <paramref name="types" /> is empty or contains all <see langword="null" />
|
||||
/// values.
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The declarative mechanism of registering model binders with Autofac
|
||||
/// is through use of <see cref="Autofac.Integration.Mvc.RegistrationExtensions.RegisterModelBinders"/>
|
||||
/// and the <see cref="Autofac.Integration.Mvc.ModelBinderTypeAttribute"/>.
|
||||
/// This method is an imperative alternative.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The two mechanisms are mutually exclusive. If you register a model
|
||||
/// binder using <see cref="Autofac.Integration.Mvc.RegistrationExtensions.RegisterModelBinders"/>
|
||||
/// and register the same model binder with this method, the results
|
||||
/// are not automatically merged together - standard dependency
|
||||
/// registration/resolution rules will be used to manage the conflict.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Any <see langword="null" /> values provided in <paramref name="types" />
|
||||
/// will be removed prior to registration.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> AsModelBinderForTypes<TLimit, TActivatorData, TRegistrationStyle>(this IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> registration, params Type[] types)
|
||||
where TActivatorData : IConcreteActivatorData
|
||||
where TRegistrationStyle : SingleRegistrationStyle
|
||||
{
|
||||
if (registration == null)
|
||||
{
|
||||
throw new ArgumentNullException("registration");
|
||||
}
|
||||
if (types == null)
|
||||
{
|
||||
throw new ArgumentNullException("types");
|
||||
}
|
||||
var typeList = types.Where(type => type != null).ToList();
|
||||
if (typeList.Count == 0)
|
||||
{
|
||||
throw new ArgumentException(RegistrationExtensionsResources.InvalidModelBinderType, "types");
|
||||
}
|
||||
|
||||
return registration.As<IModelBinder>().WithMetadata(AutofacModelBinderProvider.MetadataKey, typeList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register types that implement <see cref="IModelBinder"/> in the provided assemblies
|
||||
/// and have a <see cref="Autofac.Integration.Mvc.ModelBinderTypeAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="builder">The container builder.</param>
|
||||
/// <param name="modelBinderAssemblies">Assemblies to scan for model binders.</param>
|
||||
/// <returns>A registration builder.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Thrown if <paramref name="builder" /> or <paramref name="modelBinderAssemblies" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The declarative mechanism of registering model binders with Autofac
|
||||
/// is through use of this method and the
|
||||
/// <see cref="Autofac.Integration.Mvc.ModelBinderTypeAttribute"/>.
|
||||
/// If you would like more imperative control over registration for your
|
||||
/// model binders, see the <see cref="AsModelBinderForTypes{TLimit,TActivatorData,TRegistrationStyle}"/>
|
||||
/// method.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The two mechanisms are mutually exclusive. If you register a model
|
||||
/// binder using <see cref="AsModelBinderForTypes{TLimit,TActivatorData,TRegistrationStyle}"/>
|
||||
/// and register the same model binder with this method, the results
|
||||
/// are not automatically merged together - standard dependency
|
||||
/// registration/resolution rules will be used to manage the conflict.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method only registers types that implement <see cref="IModelBinder"/>
|
||||
/// and are marked with the <see cref="Autofac.Integration.Mvc.ModelBinderTypeAttribute"/>.
|
||||
/// The model binder must have the attribute because the
|
||||
/// <see cref="Autofac.Integration.Mvc.AutofacModelBinderProvider"/> uses
|
||||
/// the associated metadata - from the attribute(s) - to resolve the
|
||||
/// binder based on model type. If there aren't any attributes, there
|
||||
/// won't be any metadata, so the model binder will be technically
|
||||
/// registered but will never actually be resolved.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If your model is not marked with the attribute, or if you don't want
|
||||
/// to use attributes, use the
|
||||
/// <see cref="AsModelBinderForTypes{TLimit,TActivatorData,TRegistrationStyle}"/>
|
||||
/// extension instead.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
|
||||
RegisterModelBinders(this ContainerBuilder builder, params Assembly[] modelBinderAssemblies)
|
||||
{
|
||||
if (builder == null) throw new ArgumentNullException("builder");
|
||||
if (modelBinderAssemblies == null) throw new ArgumentNullException("modelBinderAssemblies");
|
||||
|
||||
return builder.RegisterAssemblyTypes(modelBinderAssemblies)
|
||||
.Where(type => typeof(IModelBinder).IsAssignableFrom(type) && type.GetCustomAttributes(typeof(ModelBinderTypeAttribute), true).Length > 0)
|
||||
.As<IModelBinder>()
|
||||
.InstancePerHttpRequest()
|
||||
.WithMetadata(AutofacModelBinderProvider.MetadataKey, type =>
|
||||
(from ModelBinderTypeAttribute attribute in type.GetCustomAttributes(typeof(ModelBinderTypeAttribute), true)
|
||||
from targetType in attribute.TargetTypes
|
||||
select targetType).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the <see cref="AutofacFilterProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="builder">The container builder.</param>
|
||||
public static void RegisterFilterProvider(this ContainerBuilder builder)
|
||||
{
|
||||
if (builder == null) throw new ArgumentNullException("builder");
|
||||
|
||||
foreach (var provider in FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().ToArray())
|
||||
FilterProviders.Providers.Remove(provider);
|
||||
|
||||
builder.RegisterType<AutofacFilterProvider>()
|
||||
.As<IFilterProvider>()
|
||||
.SingleInstance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache instances in the web session. This implies external ownership (disposal is not
|
||||
/// available.) All dependencies must also have external ownership.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It is strongly recommended that components cached per-session do not take dependencies on
|
||||
/// other services.
|
||||
/// </remarks>
|
||||
/// <typeparam name="TLimit">Registration limit type.</typeparam>
|
||||
/// <typeparam name="TSingleRegistrationStyle">Registration style.</typeparam>
|
||||
/// <typeparam name="TActivatorData">Activator data type.</typeparam>
|
||||
/// <param name="registration">The registration to configure.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "It is the responsibility of the registry to dispose of registrations.")]
|
||||
public static IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle>
|
||||
CacheInSession<TLimit, TActivatorData, TSingleRegistrationStyle>(
|
||||
this IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle> registration)
|
||||
where TActivatorData : IConcreteActivatorData
|
||||
where TSingleRegistrationStyle : SingleRegistrationStyle
|
||||
{
|
||||
if (registration == null) throw new ArgumentNullException("registration");
|
||||
|
||||
var services = registration.RegistrationData.Services.ToArray();
|
||||
registration.RegistrationData.ClearServices();
|
||||
|
||||
return registration
|
||||
.ExternallyOwned()
|
||||
.OnRegistered(e => e.ComponentRegistry.Register(RegistrationBuilder
|
||||
.ForDelegate((c, p) =>
|
||||
{
|
||||
var session = HttpContext.Current.Session;
|
||||
object result;
|
||||
lock (session.SyncRoot)
|
||||
{
|
||||
result = session[e.ComponentRegistration.Id.ToString()];
|
||||
if (result == null)
|
||||
{
|
||||
result = c.ResolveComponent(e.ComponentRegistration, p);
|
||||
session[e.ComponentRegistration.Id.ToString()] = result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.As(services)
|
||||
.InstancePerLifetimeScope()
|
||||
.ExternallyOwned()
|
||||
.CreateRegistration()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IActionFilter"/> for the specified controller action.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="actionSelector">The action selector.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsActionFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration,
|
||||
Expression<Action<TController>> actionSelector, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IActionFilter, TController>(registration, AutofacFilterProvider.ActionFilterMetadataKey, actionSelector, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IActionFilter"/> for the specified controller.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsActionFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IActionFilter, TController>(registration, AutofacFilterProvider.ActionFilterMetadataKey, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IAuthorizationFilter"/> for the specified controller action.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="actionSelector">The action selector.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsAuthorizationFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration,
|
||||
Expression<Action<TController>> actionSelector, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IAuthorizationFilter, TController>(registration, AutofacFilterProvider.AuthorizationFilterMetadataKey, actionSelector, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IAuthorizationFilter"/> for the specified controller.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsAuthorizationFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IAuthorizationFilter, TController>(registration, AutofacFilterProvider.AuthorizationFilterMetadataKey, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IExceptionFilter"/> for the specified controller action.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="actionSelector">The action selector.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsExceptionFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration,
|
||||
Expression<Action<TController>> actionSelector, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IExceptionFilter, TController>(registration, AutofacFilterProvider.ExceptionFilterMetadataKey, actionSelector, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IExceptionFilter"/> for the specified controller.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsExceptionFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IExceptionFilter, TController>(registration, AutofacFilterProvider.ExceptionFilterMetadataKey, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IResultFilter"/> for the specified controller action.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="actionSelector">The action selector.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsResultFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration,
|
||||
Expression<Action<TController>> actionSelector, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IResultFilter, TController>(registration, AutofacFilterProvider.ResultFilterMetadataKey, actionSelector, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provided registration to act as an <see cref="IResultFilter"/> for the specified controller.
|
||||
/// </summary>
|
||||
/// <typeparam name="TController">The type of the controller.</typeparam>
|
||||
/// <param name="registration">The registration.</param>
|
||||
/// <param name="order">The order in which the filter is applied.</param>
|
||||
/// <returns>A registration builder allowing further configuration of the component.</returns>
|
||||
public static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsResultFilterFor<TController>(this IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, int order = Filter.DefaultOrder)
|
||||
where TController : IController
|
||||
{
|
||||
return AsFilterFor<IResultFilter, TController>(registration, AutofacFilterProvider.ResultFilterMetadataKey, order);
|
||||
}
|
||||
|
||||
static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsFilterFor<TFilter, TController>(IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, string metadataKey, Expression<Action<TController>> actionSelector, int order)
|
||||
where TController : IController
|
||||
{
|
||||
if (registration == null) throw new ArgumentNullException("registration");
|
||||
if (actionSelector == null) throw new ArgumentNullException("actionSelector");
|
||||
|
||||
var limitType = registration.ActivatorData.Activator.LimitType;
|
||||
|
||||
if (!limitType.IsAssignableTo<TFilter>())
|
||||
{
|
||||
var message = string.Format(CultureInfo.CurrentCulture, RegistrationExtensionsResources.MustBeAssignableToFilterType,
|
||||
limitType.FullName, typeof(TFilter).FullName);
|
||||
throw new ArgumentException(message, "registration");
|
||||
}
|
||||
|
||||
var metadata = new FilterMetadata
|
||||
{
|
||||
ControllerType = typeof(TController),
|
||||
FilterScope = FilterScope.Action,
|
||||
MethodInfo = GetMethodInfo(actionSelector),
|
||||
Order = order
|
||||
};
|
||||
|
||||
return registration.As<TFilter>().WithMetadata(metadataKey, metadata);
|
||||
}
|
||||
|
||||
static IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle>
|
||||
AsFilterFor<TFilter, TController>(IRegistrationBuilder<object, IConcreteActivatorData, SingleRegistrationStyle> registration, string metadataKey, int order)
|
||||
where TController : IController
|
||||
{
|
||||
if (registration == null) throw new ArgumentNullException("registration");
|
||||
|
||||
var limitType = registration.ActivatorData.Activator.LimitType;
|
||||
|
||||
if (!limitType.IsAssignableTo<TFilter>())
|
||||
{
|
||||
var message = string.Format(CultureInfo.CurrentCulture, RegistrationExtensionsResources.MustBeAssignableToFilterType,
|
||||
limitType.FullName, typeof(TFilter).FullName);
|
||||
throw new ArgumentException(message, "registration");
|
||||
}
|
||||
|
||||
var metadata = new FilterMetadata
|
||||
{
|
||||
ControllerType = typeof(TController),
|
||||
FilterScope = FilterScope.Controller,
|
||||
MethodInfo = null,
|
||||
Order = order
|
||||
};
|
||||
|
||||
return registration.As<TFilter>().WithMetadata(metadataKey, metadata);
|
||||
}
|
||||
|
||||
static MethodInfo GetMethodInfo(LambdaExpression expression)
|
||||
{
|
||||
var outermostExpression = expression.Body as MethodCallExpression;
|
||||
|
||||
if (outermostExpression == null)
|
||||
throw new ArgumentException(RegistrationExtensionsResources.InvalidActionExpress);
|
||||
|
||||
return outermostExpression.Method;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18010
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Autofac.Integration.Mvc {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class RegistrationExtensionsResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal RegistrationExtensionsResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.Mvc.RegistrationExtensionsResources", typeof(RegistrationExtensionsResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The action method Expression is invalid. It should consist only of a Method call to a controller action method..
|
||||
/// </summary>
|
||||
internal static string InvalidActionExpress {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidActionExpress", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Type list may not be empty or contain all null values..
|
||||
/// </summary>
|
||||
internal static string InvalidModelBinderType {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidModelBinderType", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The type '{0}' must be assignable to the filter type '{1}'..
|
||||
/// </summary>
|
||||
internal static string MustBeAssignableToFilterType {
|
||||
get {
|
||||
return ResourceManager.GetString("MustBeAssignableToFilterType", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,122 @@
|
|||
// This software is part of the Autofac IoC container
|
||||
// Copyright (c) 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.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Web;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and disposes HTTP request based lifetime scopes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The provider is notified when a HTTP request ends by the <see cref="RequestLifetimeHttpModule"/>.
|
||||
/// </remarks>
|
||||
public class RequestLifetimeScopeProvider : ILifetimeScopeProvider
|
||||
{
|
||||
readonly ILifetimeScope _container;
|
||||
|
||||
/// <summary>
|
||||
/// Tag used to identify registrations that are scoped to the HTTP request level.
|
||||
/// </summary>
|
||||
internal static readonly object HttpRequestTag = "AutofacWebRequest";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestLifetimeScopeProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="container">The parent container, usually the application container.</param>
|
||||
public RequestLifetimeScopeProvider(ILifetimeScope container)
|
||||
{
|
||||
if (container == null) throw new ArgumentNullException("container");
|
||||
_container = container;
|
||||
RequestLifetimeHttpModule.SetLifetimeScopeProvider(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global, application-wide container.
|
||||
/// </summary>
|
||||
public ILifetimeScope ApplicationContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
static ILifetimeScope LifetimeScope
|
||||
{
|
||||
get { return (ILifetimeScope)HttpContext.Current.Items[typeof(ILifetimeScope)]; }
|
||||
set { HttpContext.Current.Items[typeof(ILifetimeScope)] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a nested lifetime scope that services can be resolved from.
|
||||
/// </summary>
|
||||
/// <param name="configurationAction">
|
||||
/// A configuration action that will execute during lifetime scope creation.
|
||||
/// </param>
|
||||
/// <returns>A new or existing nested lifetime scope.</returns>
|
||||
public ILifetimeScope GetLifetimeScope(Action<ContainerBuilder> configurationAction)
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
throw new InvalidOperationException(RequestLifetimeScopeProviderResources.HttpContextNotAvailable);
|
||||
}
|
||||
|
||||
if (LifetimeScope == null)
|
||||
{
|
||||
if ((LifetimeScope = GetLifetimeScopeCore(configurationAction)) == null)
|
||||
throw new InvalidOperationException(
|
||||
string.Format(CultureInfo.CurrentCulture, RequestLifetimeScopeProviderResources.NullLifetimeScopeReturned, GetType().FullName));
|
||||
}
|
||||
return LifetimeScope;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the current HTTP request lifetime scope.
|
||||
/// </summary>
|
||||
public void EndLifetimeScope()
|
||||
{
|
||||
var lifetimeScope = LifetimeScope;
|
||||
if (lifetimeScope != null)
|
||||
lifetimeScope.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a lifetime scope for the current HTTP request. This method can be overridden
|
||||
/// to alter the way that the life time scope is constructed.
|
||||
/// </summary>
|
||||
/// <param name="configurationAction">
|
||||
/// A configuration action that will execute during lifetime scope creation.
|
||||
/// </param>
|
||||
/// <returns>A new lifetime scope for the current HTTP request.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
protected virtual ILifetimeScope GetLifetimeScopeCore(Action<ContainerBuilder> configurationAction)
|
||||
{
|
||||
return (configurationAction == null)
|
||||
? ApplicationContainer.BeginLifetimeScope(HttpRequestTag)
|
||||
: ApplicationContainer.BeginLifetimeScope(HttpRequestTag, configurationAction);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Autofac.Integration.Mvc {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class RequestLifetimeScopeProviderResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal RequestLifetimeScopeProviderResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.Mvc.RequestLifetimeScopeProviderResources", typeof(RequestLifetimeScopeProviderResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The request lifetime scope cannot be created because the HttpContext is not available..
|
||||
/// </summary>
|
||||
internal static string HttpContextNotAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("HttpContextNotAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 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..
|
||||
/// </summary>
|
||||
internal static string NullLifetimeScopeReturned {
|
||||
get {
|
||||
return ResourceManager.GetString("NullLifetimeScopeReturned", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,78 @@
|
|||
// 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.Web.Mvc;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Core;
|
||||
|
||||
namespace Autofac.Integration.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// A registration source for building view registrations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Supports view registrations for <see cref="WebViewPage"/>, <see cref="ViewPage"/>,
|
||||
/// <see cref="ViewMasterPage"/> and <see cref="ViewUserControl"/> derived types.
|
||||
/// </remarks>
|
||||
public class ViewRegistrationSource : IRegistrationSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve registrations for an unregistered service, to be used
|
||||
/// by the container.
|
||||
/// </summary>
|
||||
/// <param name="service">The service that was requested.</param>
|
||||
/// <param name="registrationAccessor">A function that will return existing registrations for a service.</param>
|
||||
/// <returns>Registrations providing the service.</returns>
|
||||
public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
|
||||
{
|
||||
var typedService = service as IServiceWithType;
|
||||
|
||||
if (typedService != null && IsSupportedView(typedService.ServiceType))
|
||||
yield return RegistrationBuilder.ForType(typedService.ServiceType)
|
||||
.PropertiesAutowired()
|
||||
.InstancePerDependency()
|
||||
.CreateRegistration();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the registrations provided by this source are 1:1 adapters on top
|
||||
/// of other components (I.e. like Meta, Func or Owned.)
|
||||
/// </summary>
|
||||
public bool IsAdapterForIndividualComponents
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
static bool IsSupportedView(Type serviceType)
|
||||
{
|
||||
return serviceType.IsAssignableTo<WebViewPage>()
|
||||
|| serviceType.IsAssignableTo<ViewPage>()
|
||||
|| serviceType.IsAssignableTo<ViewMasterPage>()
|
||||
|| serviceType.IsAssignableTo<ViewUserControl>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -67,12 +67,17 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutoMapper">
|
||||
<HintPath>..\packages\AutoMapper.2.2.0\lib\net40\AutoMapper.dll</HintPath>
|
||||
|
@ -80,14 +85,17 @@
|
|||
<Reference Include="FluentValidation">
|
||||
<HintPath>..\packages\FluentValidation.3.4.6.0\lib\Net40\FluentValidation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.15.3\lib\net40\Nancy.dll</HintPath>
|
||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac">
|
||||
<HintPath>..\packages\Nancy.Bootstrappers.Autofac.0.15.3\lib\net40\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac, Version=0.15.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\NzbDrone.Services.Api\bin\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Aspnet">
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.15.3\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
<Reference Include="Nancy.Hosting.Aspnet, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.16.1\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -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>
|
|
@ -71,11 +71,13 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
||||
|
|
|
@ -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="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NBuilder" version="3.0.1.1" />
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NzbDrone.Backbone</RootNamespace>
|
||||
<AssemblyName>NzbDrone.Backbone</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:55352/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NzbDrone.Backbone")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NzbDrone.Backbone")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ed73d928-3270-4c84-8d9c-ee9e08dfcbd0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -71,11 +71,13 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentAssertions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -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="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
|
|
|
@ -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,22 @@
|
|||
using System;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
internal static class ExceptionFactory
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("ArgumentValidator");
|
||||
|
||||
internal static ArgumentException CreateForParamValidation(string paramName, string message)
|
||||
{
|
||||
Logger.Warn(message);
|
||||
return new ArgumentException(message, paramName);
|
||||
}
|
||||
|
||||
internal static ArgumentNullException CreateForParamNullValidation(string paramName, string message)
|
||||
{
|
||||
Logger.Warn(message);
|
||||
return new ArgumentNullException(paramName, message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System.Linq.Expressions;
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat
|
||||
{
|
||||
internal static class ExpressionExtensions
|
||||
{
|
||||
internal static string ToPath(this MemberExpression e)
|
||||
{
|
||||
var path = "";
|
||||
var parent = e.Expression as MemberExpression;
|
||||
|
||||
if (parent != null)
|
||||
path = parent.ToPath() + ".";
|
||||
|
||||
return path + e.Member.Name;
|
||||
}
|
||||
|
||||
internal static MemberExpression GetRightMostMember(this Expression e)
|
||||
{
|
||||
if (e is LambdaExpression)
|
||||
return GetRightMostMember(((LambdaExpression)e).Body);
|
||||
|
||||
if (e is MemberExpression)
|
||||
return (MemberExpression)e;
|
||||
|
||||
if (e is MethodCallExpression)
|
||||
{
|
||||
var callExpression = (MethodCallExpression)e;
|
||||
|
||||
if (callExpression.Object is MethodCallExpression || callExpression.Object is MemberExpression)
|
||||
return GetRightMostMember(callExpression.Object);
|
||||
|
||||
var member = callExpression.Arguments.Count > 0 ? callExpression.Arguments[0] : callExpression.Object;
|
||||
return GetRightMostMember(member);
|
||||
}
|
||||
|
||||
if (e is UnaryExpression)
|
||||
{
|
||||
var unaryExpression = (UnaryExpression)e;
|
||||
return GetRightMostMember(unaryExpression.Operand);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,225 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NzbDrone.Common.EnsureThat.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ExceptionMessages {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ExceptionMessages() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NzbDrone.Common.EnsureThat.Resources.ExceptionMessages", typeof(ExceptionMessages).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Empty collection is not allowed..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsEmptyCollection {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsEmptyCollection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Empty Guid is not allowed..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsEmptyGuid {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsEmptyGuid", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Expected an expression that evaluates to false..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotFalse {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotFalse", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is not greater than limit '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotGt {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotGt", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is not greater than or equal to limit '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotGte {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotGte", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is > max '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotInRange_ToHigh {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotInRange_ToHigh", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The string is too long. Must be between '{0}' and '{1}'. Must be between '{0}' and '{1}' but was '{2}' characters long..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotInRange_ToLong {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotInRange_ToLong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is < min '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotInRange_ToLow {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotInRange_ToLow", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The string is not long enough. Must be between '{0}' and '{1}' but was '{2}' characters long..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotInRange_ToShort {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotInRange_ToShort", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is not lower than limit '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotLt {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotLt", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' is not lower than or equal to limit '{1}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotLte {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotLte", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value can not be null..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotNull {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The string can't be null or empty..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotNullOrEmpty {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotNullOrEmpty", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The string can't be left empty, null or consist of only whitespaces..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotNullOrWhiteSpace {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotNullOrWhiteSpace", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The param is not of expected type: '{0}'..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotOfType {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotOfType", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Expected an expression that evaluates to true..
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_IsNotTrue {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_IsNotTrue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to value '{0}' does not match '{1}'.
|
||||
/// </summary>
|
||||
internal static string EnsureExtensions_NoMatch {
|
||||
get {
|
||||
return ResourceManager.GetString("EnsureExtensions_NoMatch", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No MemberExpression found in expression: '{0}'..
|
||||
/// </summary>
|
||||
internal static string ExpressionUtils_GetRightMostMember_NoMemberFound {
|
||||
get {
|
||||
return ResourceManager.GetString("ExpressionUtils_GetRightMostMember_NoMemberFound", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Common
|
|||
{
|
||||
public const string NZBDRONE_PATH = "NZBDRONE_PATH";
|
||||
public const string NZBDRONE_PID = "NZBDRONE_PID";
|
||||
public const string ROOT_MARKER = "NzbDrone.Web";
|
||||
public const string ROOT_MARKER = "IISExpress";
|
||||
|
||||
public static readonly char[] NewLineChars = Environment.NewLine.ToCharArray();
|
||||
|
||||
|
@ -38,7 +38,10 @@ namespace NzbDrone.Common
|
|||
|
||||
public static bool IsMono
|
||||
{
|
||||
get { return Type.GetType("Mono.Runtime") != null; }
|
||||
get
|
||||
{
|
||||
return Type.GetType("Mono.Runtime") != null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDebug
|
||||
|
|
|
@ -71,11 +71,13 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Exceptron.Client, Version=1.0.7.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
@ -99,6 +101,26 @@
|
|||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EnsureThat\Ensure.cs" />
|
||||
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureDateTimeExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureDecimalExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureDoubleExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureGuidExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureIntExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureLongExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureNullableValueTypeExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureObjectExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureShortExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureStringExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureTypeExtensions.cs" />
|
||||
<Compile Include="EnsureThat\ExceptionFactory.cs" />
|
||||
<Compile Include="EnsureThat\ExpressionExtensions.cs" />
|
||||
<Compile Include="EnsureThat\Param.cs" />
|
||||
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
|
||||
<Compile Include="EnsureThat\StringExtensions.cs" />
|
||||
<Compile Include="EnsureThat\TypeParam.cs" />
|
||||
<Compile Include="StringExtention.cs" />
|
||||
<Compile Include="HttpProvider.cs" />
|
||||
<Compile Include="ConfigFileProvider.cs" />
|
||||
|
@ -126,6 +148,7 @@
|
|||
<Compile Include="SysTray\SysTrayProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="EnsureThat\ve-3BAF.tmp" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -139,6 +162,9 @@
|
|||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="EnsureThat\Resources\ExceptionMessages.resx" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -77,11 +77,13 @@
|
|||
<Reference Include="Accessibility">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutoMoq">
|
||||
<HintPath>..\packages\AutoMoq.1.6.1\lib\AutoMoq.dll</HintPath>
|
||||
|
|
|
@ -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="AutoMoq" version="1.6.1" targetFramework="net40" />
|
||||
<package id="CommonServiceLocator" version="1.0" targetFramework="net40" />
|
||||
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
|
|
|
@ -154,11 +154,13 @@
|
|||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DataTables.Mvc.Core, Version=0.1.0.85, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -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="DataTables.Mvc.Core" version="0.1.0.85" />
|
||||
<package id="DotNetZip" version="1.9.1.8" />
|
||||
<package id="Growl" version="0.6" />
|
||||
|
|
|
@ -40,11 +40,13 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutoMapper">
|
||||
<HintPath>..\packages\AutoMapper.2.2.0\lib\net40\AutoMapper.dll</HintPath>
|
||||
|
@ -56,14 +58,17 @@
|
|||
<Reference Include="MongoDB.Driver">
|
||||
<HintPath>..\packages\mongocsharpdriver.1.7\lib\net35\MongoDB.Driver.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.15.3\lib\net40\Nancy.dll</HintPath>
|
||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac">
|
||||
<HintPath>..\packages\Nancy.Bootstrappers.Autofac.0.15.3\lib\net40\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Aspnet">
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.15.3\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
<Reference Include="Nancy.Hosting.Aspnet, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.16.1\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
|
|
|
@ -19,4 +19,12 @@
|
|||
<add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -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>
|
|
@ -47,14 +47,13 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Mvc">
|
||||
<HintPath>..\..\packages\Autofac.Mvc3.2.6.3.862\lib\NET40\Autofac.Integration.Mvc.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Elmah">
|
||||
<HintPath>..\..\packages\elmah.corelibrary.1.2.1\lib\Elmah.dll</HintPath>
|
||||
|
@ -313,6 +312,10 @@
|
|||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Autofac.Integration.Mvc\Autofac.Integration.Mvc.csproj">
|
||||
<Project>{dd874e64-c7ec-464d-925f-cf4a709edeef}</Project>
|
||||
<Name>Autofac.Integration.Mvc</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.web>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac.Mvc3" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="elmah" version="1.2.0.1" />
|
||||
<package id="elmah.corelibrary" version="1.2.1" />
|
||||
<package id="elmah.sqlserver" version="1.2" />
|
||||
|
|
|
@ -89,12 +89,7 @@ namespace NzbDrone.Test.Common
|
|||
|
||||
protected string GetTestFilePath(string fileName)
|
||||
{
|
||||
return Path.Combine(@".\Files\", fileName);
|
||||
}
|
||||
|
||||
protected string ReadTestFile(string fileName)
|
||||
{
|
||||
return File.ReadAllText(GetTestFilePath(fileName));
|
||||
return Path.Combine(Directory.GetCurrentDirectory(), "Files", fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,13 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
|
|
|
@ -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>
|
|
@ -61,14 +61,13 @@
|
|||
<Reference Include="AjaxMin">
|
||||
<HintPath>..\packages\AjaxMin.4.60.4609.17023\lib\net20\AjaxMin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration">
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Mvc">
|
||||
<HintPath>..\packages\Autofac.Mvc3.2.6.3.862\lib\NET40\Autofac.Integration.Mvc.dll</HintPath>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cassette">
|
||||
<HintPath>..\packages\Cassette.2.0.0\lib\net40-client\Cassette.dll</HintPath>
|
||||
|
@ -105,12 +104,13 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy, Version=0.15.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.15.3\lib\net40\Nancy.dll</HintPath>
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Aspnet">
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.15.3\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
<Reference Include="Nancy.Hosting.Aspnet, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.16.1\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
@ -650,6 +650,10 @@
|
|||
<Folder Include="App_Data\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Autofac.Integration.Mvc\Autofac.Integration.Mvc.csproj">
|
||||
<Project>{dd874e64-c7ec-464d-925f-cf4a709edeef}</Project>
|
||||
<Name>Autofac.Integration.Mvc</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Api\NzbDrone.Api.csproj">
|
||||
<Project>{fd286df8-2d3a-4394-8ad5-443fade55fb2}</Project>
|
||||
<Name>NzbDrone.Api</Name>
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
<modules runAllManagedModulesForAllRequests="true">
|
||||
<add name="CassetteHttpModule" type="Cassette.Aspnet.CassetteHttpModule, Cassette.Aspnet" />
|
||||
</modules>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
<handlers>
|
||||
<remove name="MvcHttpHandler" />
|
||||
<remove name="UrlRoutingHandler" />
|
||||
|
@ -75,6 +74,7 @@
|
|||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
@ -90,6 +90,14 @@
|
|||
<assemblyIdentity name="dotless.ClientOnly" publicKeyToken="96b446c9e63eae34" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<location path="api" allowOverride="false">
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AjaxMin" version="4.60.4609.17023" targetFramework="net40" />
|
||||
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac.Mvc3" version="2.6.3.862" targetFramework="net40" />
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="Backbone.js" version="0.9.2" targetFramework="net40" />
|
||||
<package id="Cassette" version="2.0.0" targetFramework="net40" />
|
||||
<package id="Cassette.Aspnet" version="2.0.0" targetFramework="net40" />
|
||||
|
@ -24,8 +23,8 @@
|
|||
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20710.0" targetFramework="net40" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
|
||||
<package id="MiniProfiler" version="2.0.2" />
|
||||
<package id="Nancy" 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" />
|
||||
<package id="ServiceStack.Text" version="3.9.27" targetFramework="net40" />
|
||||
|
|
64
NzbDrone.sln
64
NzbDrone.sln
|
@ -62,6 +62,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.SqlCe", "NzbDrone.SqlCe\NzbDrone.SqlCe.csproj", "{64E5482F-0C4F-46C6-9377-699D3EADBA9E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Backbone", "NzbDrone.Backbone\NzbDrone.Backbone.csproj", "{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Integration.Mvc", "Autofac.Integration.Mvc\Autofac.Integration.Mvc.csproj", "{DD874E64-C7EC-464D-925F-CF4A709EDEEF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -714,6 +718,66 @@ Global
|
|||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Services|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Services|x64.ActiveCfg = Release|Any CPU
|
||||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Services|x86.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|x64.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Mono|x86.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|x64.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Pilot|x86.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|x64.ActiveCfg = Release|Any CPU
|
||||
{EE6B9BAC-2136-460A-87B0-709D2AC0A9AE}.Services|x86.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|x64.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Mono|x86.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|x64.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Pilot|x86.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x64.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
Help,
|
||||
InstallService,
|
||||
UninstallService,
|
||||
Service
|
||||
Service,
|
||||
Nancy
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,18 @@
|
|||
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Self, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Hosting.Self.0.16.1\lib\net40\Nancy.Hosting.Self.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -141,6 +153,10 @@
|
|||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Api\NzbDrone.Api.csproj">
|
||||
<Project>{fd286df8-2d3a-4394-8ad5-443fade55fb2}</Project>
|
||||
<Name>NzbDrone.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
|
@ -152,8 +168,9 @@
|
|||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
||||
|
||||
xcopy /s /y "$(SolutionDir)\SqlCe\*.*" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -74,13 +74,13 @@
|
|||
<IntermediateOutputPath>C:\Users\Mark\AppData\Local\Temp\vs167E.tmp\x86\Mono\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
|
@ -88,6 +88,16 @@
|
|||
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac, Version=0.15.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\NzbDrone.Services.Api\bin\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Self">
|
||||
<HintPath>..\packages\Nancy.Hosting.Self.0.16.1\lib\net40\Nancy.Hosting.Self.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -141,6 +151,10 @@
|
|||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Api\NzbDrone.Api.csproj">
|
||||
<Project>{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}</Project>
|
||||
<Name>NzbDrone.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
|
@ -152,8 +166,9 @@
|
|||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
||||
|
||||
xcopy /s /y "$(SolutionDir)\SqlCe\*.*" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using NLog;
|
||||
using Nancy.Hosting.Self;
|
||||
using NzbDrone.Api;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.SysTray;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
|
@ -19,19 +18,18 @@ namespace NzbDrone
|
|||
private readonly ServiceProvider _serviceProvider;
|
||||
private readonly ConsoleProvider _consoleProvider;
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly SysTrayProvider _sysTrayProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
|
||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider,
|
||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider,
|
||||
ProcessProvider processProvider, SysTrayProvider sysTrayProvider)
|
||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, ProcessProvider processProvider)
|
||||
{
|
||||
_applicationServer = applicationServer;
|
||||
_serviceProvider = serviceProvider;
|
||||
_consoleProvider = consoleProvider;
|
||||
_environmentProvider = environmentProvider;
|
||||
_processProvider = processProvider;
|
||||
_sysTrayProvider = sysTrayProvider;
|
||||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public void Route(IEnumerable<string> args)
|
||||
|
@ -50,6 +48,20 @@ namespace NzbDrone
|
|||
|
||||
switch (applicationMode)
|
||||
{
|
||||
case ApplicationMode.Nancy:
|
||||
{
|
||||
|
||||
var nancyHost = new NancyHost(new Uri("http://localhost:8282"), new Bootstrapper());
|
||||
nancyHost.Start();
|
||||
|
||||
|
||||
_processProvider.Start("http://localhost:8282");
|
||||
|
||||
_consoleProvider.WaitForClose();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ApplicationMode.Service:
|
||||
{
|
||||
logger.Trace("Service selected");
|
||||
|
@ -119,6 +131,7 @@ namespace NzbDrone
|
|||
|
||||
if (arg == "i") return ApplicationMode.InstallService;
|
||||
if (arg == "u") return ApplicationMode.UninstallService;
|
||||
if (arg == "n") return ApplicationMode.Nancy;
|
||||
|
||||
return ApplicationMode.Help;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<supportedRuntime version="v4.0" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -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