diff --git a/source/poodinis/container.d b/source/poodinis/container.d index d7ed7d6..a224166 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -99,7 +99,14 @@ synchronized class DependencyContainer { * See_Also: singleInstance, newInstance, existingInstance */ public Registration register(ConcreteType)() { - return register!(ConcreteType, ConcreteType)(); + return register!(ConcreteType, ConcreteType)([]); + } + + /** + * Deprecated: Use register(SuperType, ConcreteType)(RegistrationOption[]) instead + */ + public Registration register(SuperType, ConcreteType : SuperType)(RegistrationOption options...) { + return register!(SuperType, ConcreteType)(options); } /** @@ -119,7 +126,7 @@ synchronized class DependencyContainer { * * See_Also: singleInstance, newInstance, existingInstance, RegistrationOptions */ - public Registration register(SuperType, ConcreteType : SuperType, RegistrationOptionsTuple...)(RegistrationOptionsTuple options) { + public Registration register(SuperType, ConcreteType : SuperType)(RegistrationOption[] options = []) { TypeInfo registeredType = typeid(SuperType); TypeInfo_Class concreteType = typeid(ConcreteType); @@ -146,7 +153,7 @@ synchronized class DependencyContainer { return newRegistration; } - private bool hasOption(OptionType, OptionsTuple...)(OptionsTuple options, OptionType[] persistentOptions, OptionType option) { + private bool hasOption(OptionType)(OptionType[] options, shared(OptionType[]) persistentOptions, OptionType option) { foreach (presentOption; persistentOptions) { // DEPRECATED LEGACY COMPATIBILITY - REMOVE REMOVE REMOVE REMOVE REMOVE REMOVE (SOON) if (presentOption == RegistrationOption.DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION) { diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index ddfde4a..9f12203 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -497,7 +497,7 @@ version(unittest) { // Test registering type with option doNotAddConcreteTypeRegistration unittest { shared(DependencyContainer) container = new DependencyContainer(); - container.register!(TestInterface, TestClass)(RegistrationOption.doNotAddConcreteTypeRegistration); + container.register!(TestInterface, TestClass)([RegistrationOption.doNotAddConcreteTypeRegistration]); auto firstInstance = container.resolve!TestInterface; assertThrown!ResolveException(container.resolve!TestClass); @@ -506,7 +506,15 @@ version(unittest) { // Test registering type with option DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION (DEPRECATED) unittest { shared(DependencyContainer) container = new DependencyContainer(); - container.register!(TestInterface, TestClass)(RegistrationOption.DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION); + container.register!(TestInterface, TestClass)([RegistrationOption.DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION]); + + auto firstInstance = container.resolve!TestInterface; + assertThrown!ResolveException(container.resolve!TestClass); + } + // Test registering type with options in the DEPRECATED way + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.register!(TestInterface, TestClass)(RegistrationOption.doNotAddConcreteTypeRegistration); auto firstInstance = container.resolve!TestInterface; assertThrown!ResolveException(container.resolve!TestClass);