upgraded nancy bootstrapers to 0.18.0
This commit is contained in:
parent
bd4bd47e4e
commit
93b0cf4be9
|
@ -44,18 +44,6 @@ namespace NzbDrone.Api
|
||||||
return _tinyIoCContainer;
|
return _tinyIoCContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override NancyInternalConfiguration InternalConfiguration
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var internalConfig = NancyInternalConfiguration.Default;
|
|
||||||
|
|
||||||
internalConfig.StatusCodeHandlers.Add(typeof(ErrorHandler));
|
|
||||||
internalConfig.Serializers.Add(typeof(NancyJsonSerializer));
|
|
||||||
|
|
||||||
return internalConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DiagnosticsConfiguration DiagnosticsConfiguration
|
protected override DiagnosticsConfiguration DiagnosticsConfiguration
|
||||||
{
|
{
|
||||||
|
@ -76,10 +64,5 @@ namespace NzbDrone.Api
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
|
||||||
ApplicationContainer.Resolve<IMessageAggregator>().PublishEvent(new ApplicationShutdownRequested());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,12 +46,13 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.1.3\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
|
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.1.3\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Nancy, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
<HintPath>..\packages\Nancy.0.18.0\lib\net40\Nancy.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Nancy.Authentication.Basic">
|
<Reference Include="Nancy.Authentication.Basic, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Nancy.Authentication.Basic.0.16.1\lib\net40\Nancy.Authentication.Basic.dll</HintPath>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Nancy.Authentication.Basic.0.18.0\lib\net40\Nancy.Authentication.Basic.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|
|
@ -9,25 +9,50 @@ using TinyIoC;
|
||||||
|
|
||||||
namespace NzbDrone.Api
|
namespace NzbDrone.Api
|
||||||
{
|
{
|
||||||
public abstract class TinyIoCNancyBootstrapper : NancyBootstrapperWithRequestContainerBase<TinyIoCContainer>
|
public class TinyIoCNancyBootstrapper : NancyBootstrapperWithRequestContainerBase<TinyIoCContainer>
|
||||||
{
|
{
|
||||||
|
// <summary>
|
||||||
|
/// Default assemblies that are ignored for autoregister
|
||||||
|
/// </summary>
|
||||||
|
private static readonly IEnumerable<Func<Assembly, bool>> DefaultAutoRegisterIgnoredAssemblies = new Func<Assembly, bool>[]
|
||||||
|
{
|
||||||
|
asm => !asm.FullName.StartsWith("Nancy.", StringComparison.InvariantCulture),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the assemblies to ignore when autoregistering the application container
|
||||||
|
/// Return true from the delegate to ignore that particular assembly, returning true
|
||||||
|
/// does not mean the assembly *will* be included, a false from another delegate will
|
||||||
|
/// take precedence.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual IEnumerable<Func<Assembly, bool>> AutoRegisterIgnoredAssemblies
|
||||||
|
{
|
||||||
|
get { return DefaultAutoRegisterIgnoredAssemblies; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the container using AutoRegister followed by registration
|
||||||
|
/// of default INancyModuleCatalog and IRouteResolver.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="container">Container instance</param>
|
||||||
|
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
|
||||||
|
{
|
||||||
|
AutoRegister(container, this.AutoRegisterIgnoredAssemblies);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolve INancyEngine
|
/// Resolve INancyEngine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>INancyEngine implementation</returns>
|
/// <returns>INancyEngine implementation</returns>
|
||||||
protected override sealed INancyEngine GetEngineInternal()
|
protected override sealed INancyEngine GetEngineInternal()
|
||||||
{
|
{
|
||||||
return ApplicationContainer.Resolve<INancyEngine>();
|
return this.ApplicationContainer.Resolve<INancyEngine>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/* protected override IModuleKeyGenerator GetModuleKeyGenerator()
|
||||||
/// Get the moduleKey generator
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IModuleKeyGenerator instance</returns>
|
|
||||||
protected override sealed IModuleKeyGenerator GetModuleKeyGenerator()
|
|
||||||
{
|
{
|
||||||
return ApplicationContainer.Resolve<IModuleKeyGenerator>();
|
return ApplicationContainer.Resolve<IModuleKeyGenerator>();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a default, unconfigured, container
|
/// Create a default, unconfigured, container
|
||||||
|
@ -72,7 +97,7 @@ namespace NzbDrone.Api
|
||||||
{
|
{
|
||||||
foreach (var collectionTypeRegistration in collectionTypeRegistrationsn)
|
foreach (var collectionTypeRegistration in collectionTypeRegistrationsn)
|
||||||
{
|
{
|
||||||
container.RegisterMultiple(collectionTypeRegistration.RegistrationType, collectionTypeRegistration.ImplementationTypes.Distinct());
|
container.RegisterMultiple(collectionTypeRegistration.RegistrationType, collectionTypeRegistration.ImplementationTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +113,7 @@ namespace NzbDrone.Api
|
||||||
container.Register(
|
container.Register(
|
||||||
typeof(INancyModule),
|
typeof(INancyModule),
|
||||||
moduleRegistrationType.ModuleType,
|
moduleRegistrationType.ModuleType,
|
||||||
moduleRegistrationType.ModuleKey).
|
moduleRegistrationType.ModuleType.FullName).
|
||||||
AsSingleton();
|
AsSingleton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,16 +139,16 @@ namespace NzbDrone.Api
|
||||||
/// <returns>Request container instance</returns>
|
/// <returns>Request container instance</returns>
|
||||||
protected override sealed TinyIoCContainer CreateRequestContainer()
|
protected override sealed TinyIoCContainer CreateRequestContainer()
|
||||||
{
|
{
|
||||||
return ApplicationContainer.GetChildContainer();
|
return this.ApplicationContainer.GetChildContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the diagnostics for intialisation
|
/// Gets the diagnostics for initialisation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IDagnostics implementation</returns>
|
/// <returns>IDiagnostics implementation</returns>
|
||||||
protected override IDiagnostics GetDiagnostics()
|
protected override IDiagnostics GetDiagnostics()
|
||||||
{
|
{
|
||||||
return ApplicationContainer.Resolve<IDiagnostics>();
|
return this.ApplicationContainer.Resolve<IDiagnostics>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -132,7 +157,7 @@ namespace NzbDrone.Api
|
||||||
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns>
|
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns>
|
||||||
protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
|
protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
|
||||||
{
|
{
|
||||||
return ApplicationContainer.ResolveAll<IApplicationStartup>(false);
|
return this.ApplicationContainer.ResolveAll<IApplicationStartup>(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -141,7 +166,7 @@ namespace NzbDrone.Api
|
||||||
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns>
|
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns>
|
||||||
protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks()
|
protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks()
|
||||||
{
|
{
|
||||||
return ApplicationContainer.ResolveAll<IApplicationRegistrations>(false);
|
return this.ApplicationContainer.ResolveAll<IApplicationRegistrations>(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -156,14 +181,16 @@ namespace NzbDrone.Api
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retreive a specific module instance from the container by its key
|
/// Retreive a specific module instance from the container
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="container">Container to use</param>
|
/// <param name="container">Container to use</param>
|
||||||
/// <param name="moduleKey">Module key of the module</param>
|
/// <param name="moduleType">Type of the module</param>
|
||||||
/// <returns>NancyModule instance</returns>
|
/// <returns>NancyModule instance</returns>
|
||||||
protected override sealed INancyModule GetModuleByKey(TinyIoCContainer container, string moduleKey)
|
protected override sealed INancyModule GetModule(TinyIoCContainer container, Type moduleType)
|
||||||
{
|
{
|
||||||
return container.Resolve<INancyModule>(moduleKey);
|
container.Register(typeof(INancyModule), moduleType);
|
||||||
|
|
||||||
|
return container.Resolve<INancyModule>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -176,7 +203,7 @@ namespace NzbDrone.Api
|
||||||
|
|
||||||
var whitelist = new Type[] { };
|
var whitelist = new Type[] { };
|
||||||
|
|
||||||
container.AutoRegister(AppDomain.CurrentDomain.GetAssemblies().Where(a => !ignoredAssemblies.Any(ia => ia(a))), t => t.Assembly != assembly || whitelist.Any(wt => wt == t));
|
container.AutoRegister(AppDomain.CurrentDomain.GetAssemblies().Where(a => !ignoredAssemblies.Any(ia => ia(a))), DuplicateImplementationActions.RegisterMultiple, t => t.Assembly != assembly || whitelist.Any(wt => wt == t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
<packages>
|
<packages>
|
||||||
<package id="FluentValidation" version="4.0.0.1" targetFramework="net40" />
|
<package id="FluentValidation" version="4.0.0.1" targetFramework="net40" />
|
||||||
<package id="Microsoft.AspNet.SignalR.Core" version="1.1.3" targetFramework="net40" />
|
<package id="Microsoft.AspNet.SignalR.Core" version="1.1.3" targetFramework="net40" />
|
||||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Nancy.Authentication.Basic" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy.Authentication.Basic" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
||||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||||
<package id="ValueInjecter" version="2.3.3" targetFramework="net40" />
|
<package id="ValueInjecter" version="2.3.3" targetFramework="net40" />
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
// depending on platform features. If the platform has an appropriate
|
// depending on platform features. If the platform has an appropriate
|
||||||
// #DEFINE then these should be set automatically below.
|
// #DEFINE then these should be set automatically below.
|
||||||
|
|
||||||
|
|
||||||
#define EXPRESSIONS // Platform supports System.Linq.Expressions
|
#define EXPRESSIONS // Platform supports System.Linq.Expressions
|
||||||
#define COMPILED_EXPRESSIONS // Platform supports compiling expressions
|
#define COMPILED_EXPRESSIONS // Platform supports compiling expressions
|
||||||
#define APPDOMAIN_GETASSEMBLIES // Platform supports getting all assemblies from the AppDomain object
|
#define APPDOMAIN_GETASSEMBLIES // Platform supports getting all assemblies from the AppDomain object
|
||||||
|
@ -71,12 +70,13 @@ namespace TinyIoC
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
#if EXPRESSIONS
|
#if EXPRESSIONS
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using NLog;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -708,6 +708,13 @@ namespace TinyIoC
|
||||||
Fail
|
Fail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DuplicateImplementationActions
|
||||||
|
{
|
||||||
|
RegisterSingle,
|
||||||
|
RegisterMultiple,
|
||||||
|
Fail
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolution settings
|
/// Resolution settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1025,7 +1032,7 @@ namespace TinyIoC
|
||||||
public void AutoRegister()
|
public void AutoRegister()
|
||||||
{
|
{
|
||||||
#if APPDOMAIN_GETASSEMBLIES
|
#if APPDOMAIN_GETASSEMBLIES
|
||||||
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), true, null);
|
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), DuplicateImplementationActions.RegisterSingle, null);
|
||||||
#else
|
#else
|
||||||
AutoRegisterInternal(new Assembly[] {this.GetType().Assembly()}, true, null);
|
AutoRegisterInternal(new Assembly[] {this.GetType().Assembly()}, true, null);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1042,7 +1049,7 @@ namespace TinyIoC
|
||||||
public void AutoRegister(Func<Type, bool> registrationPredicate)
|
public void AutoRegister(Func<Type, bool> registrationPredicate)
|
||||||
{
|
{
|
||||||
#if APPDOMAIN_GETASSEMBLIES
|
#if APPDOMAIN_GETASSEMBLIES
|
||||||
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), true, registrationPredicate);
|
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), DuplicateImplementationActions.RegisterSingle, registrationPredicate);
|
||||||
#else
|
#else
|
||||||
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly()}, true, registrationPredicate);
|
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly()}, true, registrationPredicate);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1051,12 +1058,12 @@ namespace TinyIoC
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
|
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ignoreDuplicateImplementations">Whether to ignore duplicate implementations of an interface/base class. False=throw an exception</param>
|
/// <param name="duplicateAction">What action to take when encountering duplicate implementations of an interface/base class.</param>
|
||||||
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
||||||
public void AutoRegister(bool ignoreDuplicateImplementations)
|
public void AutoRegister(DuplicateImplementationActions duplicateAction)
|
||||||
{
|
{
|
||||||
#if APPDOMAIN_GETASSEMBLIES
|
#if APPDOMAIN_GETASSEMBLIES
|
||||||
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), ignoreDuplicateImplementations, null);
|
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), duplicateAction, null);
|
||||||
#else
|
#else
|
||||||
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly() }, ignoreDuplicateImplementations, null);
|
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly() }, ignoreDuplicateImplementations, null);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1066,13 +1073,13 @@ namespace TinyIoC
|
||||||
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
|
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
|
||||||
/// Types will only be registered if they pass the supplied registration predicate.
|
/// Types will only be registered if they pass the supplied registration predicate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ignoreDuplicateImplementations">Whether to ignore duplicate implementations of an interface/base class. False=throw an exception</param>
|
/// <param name="duplicateAction">What action to take when encountering duplicate implementations of an interface/base class.</param>
|
||||||
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
||||||
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
||||||
public void AutoRegister(bool ignoreDuplicateImplementations, Func<Type, bool> registrationPredicate)
|
public void AutoRegister(DuplicateImplementationActions duplicateAction, Func<Type, bool> registrationPredicate)
|
||||||
{
|
{
|
||||||
#if APPDOMAIN_GETASSEMBLIES
|
#if APPDOMAIN_GETASSEMBLIES
|
||||||
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), ignoreDuplicateImplementations, registrationPredicate);
|
AutoRegisterInternal(AppDomain.CurrentDomain.GetAssemblies().Where(a => !IsIgnoredAssembly(a)), duplicateAction, registrationPredicate);
|
||||||
#else
|
#else
|
||||||
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly() }, ignoreDuplicateImplementations, registrationPredicate);
|
AutoRegisterInternal(new Assembly[] { this.GetType().Assembly() }, ignoreDuplicateImplementations, registrationPredicate);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1087,7 +1094,7 @@ namespace TinyIoC
|
||||||
/// <param name="assemblies">Assemblies to process</param>
|
/// <param name="assemblies">Assemblies to process</param>
|
||||||
public void AutoRegister(IEnumerable<Assembly> assemblies)
|
public void AutoRegister(IEnumerable<Assembly> assemblies)
|
||||||
{
|
{
|
||||||
AutoRegisterInternal(assemblies, true, null);
|
AutoRegisterInternal(assemblies, DuplicateImplementationActions.RegisterSingle, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1101,18 +1108,18 @@ namespace TinyIoC
|
||||||
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
||||||
public void AutoRegister(IEnumerable<Assembly> assemblies, Func<Type, bool> registrationPredicate)
|
public void AutoRegister(IEnumerable<Assembly> assemblies, Func<Type, bool> registrationPredicate)
|
||||||
{
|
{
|
||||||
AutoRegisterInternal(assemblies, true, registrationPredicate);
|
AutoRegisterInternal(assemblies, DuplicateImplementationActions.RegisterSingle, registrationPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to automatically register all non-generic classes and interfaces in the specified assemblies
|
/// Attempt to automatically register all non-generic classes and interfaces in the specified assemblies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assemblies">Assemblies to process</param>
|
/// <param name="assemblies">Assemblies to process</param>
|
||||||
/// <param name="ignoreDuplicateImplementations">Whether to ignore duplicate implementations of an interface/base class. False=throw an exception</param>
|
/// <param name="duplicateAction">What action to take when encountering duplicate implementations of an interface/base class.</param>
|
||||||
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
||||||
public void AutoRegister(IEnumerable<Assembly> assemblies, bool ignoreDuplicateImplementations)
|
public void AutoRegister(IEnumerable<Assembly> assemblies, DuplicateImplementationActions duplicateAction)
|
||||||
{
|
{
|
||||||
AutoRegisterInternal(assemblies, ignoreDuplicateImplementations, null);
|
AutoRegisterInternal(assemblies, duplicateAction, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1120,12 +1127,12 @@ namespace TinyIoC
|
||||||
/// Types will only be registered if they pass the supplied registration predicate.
|
/// Types will only be registered if they pass the supplied registration predicate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assemblies">Assemblies to process</param>
|
/// <param name="assemblies">Assemblies to process</param>
|
||||||
/// <param name="ignoreDuplicateImplementations">Whether to ignore duplicate implementations of an interface/base class. False=throw an exception</param>
|
/// <param name="duplicateAction">What action to take when encountering duplicate implementations of an interface/base class.</param>
|
||||||
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
/// <param name="registrationPredicate">Predicate to determine if a particular type should be registered</param>
|
||||||
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
/// <exception cref="TinyIoCAutoRegistrationException"/>
|
||||||
public void AutoRegister(IEnumerable<Assembly> assemblies, bool ignoreDuplicateImplementations, Func<Type, bool> registrationPredicate)
|
public void AutoRegister(IEnumerable<Assembly> assemblies, DuplicateImplementationActions duplicateAction, Func<Type, bool> registrationPredicate)
|
||||||
{
|
{
|
||||||
AutoRegisterInternal(assemblies, ignoreDuplicateImplementations, registrationPredicate);
|
AutoRegisterInternal(assemblies, duplicateAction, registrationPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3050,7 +3057,7 @@ namespace TinyIoC
|
||||||
|
|
||||||
#region Internal Methods
|
#region Internal Methods
|
||||||
private readonly object _AutoRegisterLock = new object();
|
private readonly object _AutoRegisterLock = new object();
|
||||||
private void AutoRegisterInternal(IEnumerable<Assembly> assemblies, bool ignoreDuplicateImplementations, Func<Type, bool> registrationPredicate)
|
private void AutoRegisterInternal(IEnumerable<Assembly> assemblies, DuplicateImplementationActions duplicateAction, Func<Type, bool> registrationPredicate)
|
||||||
{
|
{
|
||||||
lock (_AutoRegisterLock)
|
lock (_AutoRegisterLock)
|
||||||
{
|
{
|
||||||
|
@ -3083,9 +3090,17 @@ namespace TinyIoC
|
||||||
where localType.IsAssignableFrom(implementationType)
|
where localType.IsAssignableFrom(implementationType)
|
||||||
select implementationType;
|
select implementationType;
|
||||||
|
|
||||||
if (!ignoreDuplicateImplementations && implementations.Count() > 1)
|
if (implementations.Count() > 1)
|
||||||
|
{
|
||||||
|
if (duplicateAction == DuplicateImplementationActions.Fail)
|
||||||
throw new TinyIoCAutoRegistrationException(type, implementations);
|
throw new TinyIoCAutoRegistrationException(type, implementations);
|
||||||
|
|
||||||
|
if (duplicateAction == DuplicateImplementationActions.RegisterMultiple)
|
||||||
|
{
|
||||||
|
RegisterMultiple(type, implementations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var firstImplementation = implementations.FirstOrDefault();
|
var firstImplementation = implementations.FirstOrDefault();
|
||||||
if (firstImplementation != null)
|
if (firstImplementation != null)
|
||||||
{
|
{
|
||||||
|
@ -3815,6 +3830,7 @@ namespace TinyIoC
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse shim for WinRT SR changes...
|
// reverse shim for WinRT SR changes...
|
||||||
|
|
|
@ -89,12 +89,13 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Microsoft.Owin.Hosting.1.1.0-beta2\lib\net40\Microsoft.Owin.Hosting.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Owin.Hosting.1.1.0-beta2\lib\net40\Microsoft.Owin.Hosting.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Nancy">
|
<Reference Include="Nancy, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Nancy.Owin, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Nancy.Owin.0.16.1\lib\net40\Nancy.Owin.dll</HintPath>
|
<HintPath>..\packages\Nancy.0.18.0\lib\net40\Nancy.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Nancy.Owin, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Nancy.Owin.0.18.0\lib\net40\Nancy.Owin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Host.Owin.MiddleWare
|
||||||
|
|
||||||
public void Attach(IAppBuilder appBuilder)
|
public void Attach(IAppBuilder appBuilder)
|
||||||
{
|
{
|
||||||
var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper);
|
var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper, new HostConfiguration());
|
||||||
appBuilder.Use((Func<Func<IDictionary<string, object>, Task>, Func<IDictionary<string, object>, Task>>)(next => (Func<IDictionary<string, object>, Task>)nancyOwinHost.Invoke), new object[0]);
|
appBuilder.Use((Func<Func<IDictionary<string, object>, Task>, Func<IDictionary<string, object>, Task>>)(next => (Func<IDictionary<string, object>, Task>)nancyOwinHost.Invoke), new object[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net40" />
|
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net40" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
||||||
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
||||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Nancy.Owin" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy.Owin" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
||||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||||
<package id="NLog.Config" version="2.0.1.2" targetFramework="net40" />
|
<package id="NLog.Config" version="2.0.1.2" targetFramework="net40" />
|
||||||
|
|
|
@ -58,12 +58,13 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Nancy">
|
<Reference Include="Nancy, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Nancy.Owin, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Nancy.Owin.0.16.1\lib\net40\Nancy.Owin.dll</HintPath>
|
<HintPath>..\packages\Nancy.0.18.0\lib\net40\Nancy.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Nancy.Owin, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Nancy.Owin.0.18.0\lib\net40\Nancy.Owin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
||||||
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
||||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Nancy.Owin" version="0.16.1" targetFramework="net40" />
|
<package id="Nancy.Owin" version="0.18.0" targetFramework="net40" />
|
||||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
||||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||||
|
|
Loading…
Reference in New Issue