From e7a29f17f779d01538ac694529d9ba89f7a59f87 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Wed, 3 Feb 2016 22:24:22 +0100 Subject: [PATCH] Allow register by concrete type to also get registration options Although the currently only available option will do nothing --- source/poodinis/container.d | 4 ++-- test/poodinis/containertest.d | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/poodinis/container.d b/source/poodinis/container.d index a224166..644415b 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -98,8 +98,8 @@ synchronized class DependencyContainer { * * See_Also: singleInstance, newInstance, existingInstance */ - public Registration register(ConcreteType)() { - return register!(ConcreteType, ConcreteType)([]); + public Registration register(ConcreteType)(RegistrationOption[] options = []) { + return register!(ConcreteType, ConcreteType)(options); } /** diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 9f12203..9f4cbbc 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -511,6 +511,14 @@ version(unittest) { auto firstInstance = container.resolve!TestInterface; assertThrown!ResolveException(container.resolve!TestClass); } + + // Test registering conrete type with registration option doNotAddConcreteTypeRegistration does nothing + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.register!TestClass([RegistrationOption.doNotAddConcreteTypeRegistration]); + container.resolve!TestClass; + } + // Test registering type with options in the DEPRECATED way unittest { shared(DependencyContainer) container = new DependencyContainer();