From cf58e52f401eaa19f03da9887b3cfc338915018d Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 8 Dec 2016 18:02:19 -0800 Subject: [PATCH] Upgraded Nancy!!!! --- src/NzbDrone.Api/NzbDrone.Api.csproj | 17 ++++---- src/NzbDrone.Api/TinyIoCNancyBootstrapper.cs | 40 ++++++++++--------- src/NzbDrone.Api/packages.config | 6 +-- src/NzbDrone.Host/NzbDrone.Host.csproj | 12 +++--- src/NzbDrone.Host/packages.config | 4 +- .../NzbDrone.Integration.Test.csproj | 12 +++--- src/NzbDrone.Integration.Test/packages.config | 4 +- 7 files changed, 50 insertions(+), 45 deletions(-) diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index f497eeb06..a259bfd5a 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -44,16 +44,17 @@ ..\packages\FluentValidation.6.2.1.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll True - - False - ..\packages\Nancy.0.23.2\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True - - False - ..\packages\Nancy.Authentication.Basic.0.23.2\lib\net40\Nancy.Authentication.Basic.dll + + ..\packages\Nancy.Authentication.Basic.1.4.1\lib\net40\Nancy.Authentication.Basic.dll + True - - ..\packages\Nancy.Authentication.Forms.0.23.2\lib\net40\Nancy.Authentication.Forms.dll + + ..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll + True False diff --git a/src/NzbDrone.Api/TinyIoCNancyBootstrapper.cs b/src/NzbDrone.Api/TinyIoCNancyBootstrapper.cs index 02d6ee603..d2474352f 100644 --- a/src/NzbDrone.Api/TinyIoCNancyBootstrapper.cs +++ b/src/NzbDrone.Api/TinyIoCNancyBootstrapper.cs @@ -1,28 +1,34 @@ -using System; +using TinyIoC; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Nancy; -using Nancy.Bootstrapper; using Nancy.Diagnostics; -using TinyIoC; +using Nancy.Bootstrapper; namespace NzbDrone.Api { + + + /// + /// TinyIoC bootstrapper - registers default route resolver and registers itself as + /// INancyModuleCatalog for resolving modules but behaviour can be overridden if required. + /// public class TinyIoCNancyBootstrapper : NancyBootstrapperWithRequestContainerBase { - // + /// /// Default assemblies that are ignored for autoregister /// - private static readonly IEnumerable> DefaultAutoRegisterIgnoredAssemblies = new Func[] + public static IEnumerable> DefaultAutoRegisterIgnoredAssemblies = new Func[] { asm => !asm.FullName.StartsWith("Nancy.", StringComparison.InvariantCulture), }; /// /// 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 + /// Return true from the delegate to ignore that particular assembly, returning false + /// does not mean the assembly *will* be included, a true from another delegate will /// take precedence. /// protected virtual IEnumerable> AutoRegisterIgnoredAssemblies @@ -49,11 +55,6 @@ namespace NzbDrone.Api return this.ApplicationContainer.Resolve(); } - /* protected override IModuleKeyGenerator GetModuleKeyGenerator() - { - return ApplicationContainer.Resolve(); - }*/ - /// /// Create a default, unconfigured, container /// @@ -93,6 +94,7 @@ namespace NzbDrone.Api break; case Lifetime.PerRequest: throw new InvalidOperationException("Unable to directly register a per request lifetime."); + break; default: throw new ArgumentOutOfRangeException(); } @@ -104,10 +106,10 @@ namespace NzbDrone.Api /// by IEnumerable{Type} constructor dependencies. /// /// Container to register into - /// Collection type registrations to register - protected override sealed void RegisterCollectionTypes(TinyIoCContainer container, IEnumerable collectionTypeRegistrationsn) + /// Collection type registrations to register + protected override sealed void RegisterCollectionTypes(TinyIoCContainer container, IEnumerable collectionTypeRegistrations) { - foreach (var collectionTypeRegistration in collectionTypeRegistrationsn) + foreach (var collectionTypeRegistration in collectionTypeRegistrations) { switch (collectionTypeRegistration.Lifetime) { @@ -119,6 +121,7 @@ namespace NzbDrone.Api break; case Lifetime.PerRequest: throw new InvalidOperationException("Unable to directly register a per request lifetime."); + break; default: throw new ArgumentOutOfRangeException(); } @@ -160,8 +163,9 @@ namespace NzbDrone.Api /// /// Creates a per request child/nested container /// + /// Current context /// Request container instance - protected override sealed TinyIoCContainer CreateRequestContainer() + protected override TinyIoCContainer CreateRequestContainer(NancyContext context) { return this.ApplicationContainer.GetChildContainer(); } @@ -216,7 +220,7 @@ namespace NzbDrone.Api } /// - /// Retreive a specific module instance from the container + /// Retrieve a specific module instance from the container /// /// Container to use /// Type of the module @@ -239,4 +243,4 @@ namespace NzbDrone.Api container.AutoRegister(AppDomain.CurrentDomain.GetAssemblies().Where(a => !ignoredAssemblies.Any(ia => ia(a))), DuplicateImplementationActions.RegisterMultiple, t => t.Assembly != assembly); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Api/packages.config b/src/NzbDrone.Api/packages.config index cb1774c30..edd4daeac 100644 --- a/src/NzbDrone.Api/packages.config +++ b/src/NzbDrone.Api/packages.config @@ -2,9 +2,9 @@ - - - + + + \ No newline at end of file diff --git a/src/NzbDrone.Host/NzbDrone.Host.csproj b/src/NzbDrone.Host/NzbDrone.Host.csproj index 62a907ab6..221bb07e5 100644 --- a/src/NzbDrone.Host/NzbDrone.Host.csproj +++ b/src/NzbDrone.Host/NzbDrone.Host.csproj @@ -69,13 +69,13 @@ False ..\packages\Microsoft.Owin.Hosting.2.1.0\lib\net40\Microsoft.Owin.Hosting.dll - - False - ..\packages\Nancy.0.23.2\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True - - False - ..\packages\Nancy.Owin.0.23.2\lib\net40\Nancy.Owin.dll + + ..\packages\Nancy.Owin.1.4.1\lib\net40\Nancy.Owin.dll + True False diff --git a/src/NzbDrone.Host/packages.config b/src/NzbDrone.Host/packages.config index 8fde86d4a..41c5dc8a7 100644 --- a/src/NzbDrone.Host/packages.config +++ b/src/NzbDrone.Host/packages.config @@ -3,8 +3,8 @@ - - + + diff --git a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj index 842890f7c..8e4d230c0 100644 --- a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj +++ b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj @@ -64,13 +64,13 @@ False ..\packages\Microsoft.Owin.Hosting.2.1.0\lib\net40\Microsoft.Owin.Hosting.dll - - False - ..\packages\Nancy.0.23.2\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True - - False - ..\packages\Nancy.Owin.0.23.2\lib\net40\Nancy.Owin.dll + + ..\packages\Nancy.Owin.1.4.1\lib\net40\Nancy.Owin.dll + True False diff --git a/src/NzbDrone.Integration.Test/packages.config b/src/NzbDrone.Integration.Test/packages.config index 1da007e4a..59b71b76e 100644 --- a/src/NzbDrone.Integration.Test/packages.config +++ b/src/NzbDrone.Integration.Test/packages.config @@ -7,8 +7,8 @@ - - + +