From f951a8b7baf64ad5a46ac3b4bf2d803e06d1fb85 Mon Sep 17 00:00:00 2001 From: Jonathan Channon Date: Fri, 29 Aug 2014 16:05:40 +0100 Subject: [PATCH 1/2] requestscopedtype fix being overwritten --- .../NancyBootstrapperWithRequestContainerBase.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs b/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs index d6258030e4..3a557a016f 100644 --- a/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs +++ b/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs @@ -14,6 +14,10 @@ namespace Nancy.Bootstrapper public abstract class NancyBootstrapperWithRequestContainerBase : NancyBootstrapperBase where TContainer : class { + protected NancyBootstrapperWithRequestContainerBase() + { + this.RequestScopedTypes = new TypeRegistration[0]; + } /// /// Context key for storing the child container in the context /// @@ -113,9 +117,9 @@ protected override sealed void RegisterRegistrationTasks(IEnumerable tr.Lifetime != Lifetime.PerRequest)); - this.RequestScopedTypes = applicationTypeRegistrations.Where(tr => tr.Lifetime == Lifetime.PerRequest) - .Select(tr => new TypeRegistration(tr.RegistrationType, tr.ImplementationType, Lifetime.Singleton)) - .ToArray(); + this.RequestScopedTypes = this.RequestScopedTypes.Concat(applicationTypeRegistrations.Where(tr => tr.Lifetime == Lifetime.PerRequest) + .Select(tr => new TypeRegistration(tr.RegistrationType, tr.ImplementationType, Lifetime.Singleton))) + .ToArray(); var applicationCollectionRegistrations = applicationRegistrationTask.CollectionTypeRegistrations == null ? new CollectionTypeRegistration[] { } : From a421677b24b5ba2a28718c8b46db16adace64b66 Mon Sep 17 00:00:00 2001 From: Jonathan Channon Date: Fri, 29 Aug 2014 17:12:04 +0100 Subject: [PATCH 2/2] fix for collection regsitrations --- .../NancyBootstrapperWithRequestContainerBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs b/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs index 3a557a016f..6bb69874c9 100644 --- a/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs +++ b/src/Nancy/Bootstrapper/NancyBootstrapperWithRequestContainerBase.cs @@ -17,6 +17,7 @@ public abstract class NancyBootstrapperWithRequestContainerBase : Na protected NancyBootstrapperWithRequestContainerBase() { this.RequestScopedTypes = new TypeRegistration[0]; + this.RequestScopedCollectionTypes = new CollectionTypeRegistration[0]; } /// /// Context key for storing the child container in the context @@ -126,8 +127,8 @@ protected override sealed void RegisterRegistrationTasks(IEnumerable tr.Lifetime != Lifetime.PerRequest)); - this.RequestScopedCollectionTypes = applicationCollectionRegistrations.Where(tr => tr.Lifetime == Lifetime.PerRequest) - .Select(tr => new CollectionTypeRegistration(tr.RegistrationType, tr.ImplementationTypes, Lifetime.Singleton)) + this.RequestScopedCollectionTypes = this.RequestScopedCollectionTypes.Concat(applicationCollectionRegistrations.Where(tr => tr.Lifetime == Lifetime.PerRequest) + .Select(tr => new CollectionTypeRegistration(tr.RegistrationType, tr.ImplementationTypes, Lifetime.Singleton))) .ToArray(); var applicationInstanceRegistrations = applicationRegistrationTask.InstanceRegistrations;