diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 0258c98..d5b8aca 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -24,6 +24,7 @@ debug { import poodinis.registration; import poodinis.autowire; import poodinis.context; +import poodinis.factory; /** * Exception thrown when errors occur while resolving a type in a dependency container. @@ -147,6 +148,7 @@ synchronized class DependencyContainer { } auto newRegistration = new AutowiredRegistration!ConcreteType(registeredType, this); + newRegistration.instanceFactory = new InstanceFactory(); newRegistration.singleInstance(); static if (!is(SuperType == ConcreteType)) { diff --git a/source/poodinis/context.d b/source/poodinis/context.d index 0054c25..a953c4a 100644 --- a/source/poodinis/context.d +++ b/source/poodinis/context.d @@ -38,7 +38,7 @@ struct RegisterByType(Type) { } /** -* Components with the prototype registration will be scoped as dependencies which will created +* Components with the prototype registration will be scoped as dependencies which will create * new instances every time they are resolved. The factory method will be called repeatedly. */ struct Prototype {} diff --git a/source/poodinis/registration.d b/source/poodinis/registration.d index 9922baf..5bcab36 100644 --- a/source/poodinis/registration.d +++ b/source/poodinis/registration.d @@ -67,7 +67,6 @@ class Registration { * Effectively makes the given registration a singleton. */ public Registration singleInstance(Registration registration) { - registration.instanceFactory = new InstanceFactory(); registration.instanceFactory.factoryParameters = InstanceFactoryParameters(registration.instanceType, CreatesSingleton.yes); return registration; } @@ -76,7 +75,6 @@ public Registration singleInstance(Registration registration) { * Scopes registrations to return a new instance every time the given registration is resolved. */ public Registration newInstance(Registration registration) { - registration.instanceFactory = new InstanceFactory(); registration.instanceFactory.factoryParameters = InstanceFactoryParameters(registration.instanceType, CreatesSingleton.no); return registration; } @@ -85,7 +83,6 @@ public Registration newInstance(Registration registration) { * Scopes registrations to return the given instance every time the given registration is resolved. */ public Registration existingInstance(Registration registration, Object instance) { - registration.instanceFactory = new InstanceFactory(); registration.instanceFactory.factoryParameters = InstanceFactoryParameters(registration.instanceType, CreatesSingleton.yes, instance); return registration; }