diff --git a/CHANGES.md b/CHANGES.md index 23252b5..dff34af 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,8 @@ Poodinis Changelog **Version 5.0.0** * DEPRECATE ADD_CONCRETE_TYPE_REGISTRATION registration option. It basically does nothing anymore. See next point. * CHANGE adding registrations by super type always registers them by concrete type as well now. (Previously done with ADD_CONCRETE_TYPE_REGISTRATION). See DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION for the reverse behaviour. +* CHANGE RegistrationOptions enum name to RegistrationOption +* DEPRECATE Usage of RegistrationOptions, please use RegistrationOption instead. **Version 4.0.0** * REMOVE deprecated module "dependency.d" diff --git a/source/poodinis/container.d b/source/poodinis/container.d index e761ae4..8d7386f 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -45,7 +45,7 @@ class RegistrationException : Exception { /** * Options which influence the process of registering dependencies */ -public enum RegistrationOptions { +public enum RegistrationOption { /** * When registering a type by its supertype, providing this option will also register * a linked registration to the type itself. @@ -77,6 +77,11 @@ public enum RegistrationOptions { DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION } +/** + * Deprecated: Use enum RegistrationOption instead + */ +alias RegistrationOptions = RegistrationOption; + /** * The dependency container maintains all dependencies registered with it. * @@ -149,7 +154,7 @@ synchronized class DependencyContainer { auto newRegistration = new AutowiredRegistration!ConcreteType(registeredType, this); newRegistration.singleInstance(); - if (!hasOption(options, RegistrationOptions.DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION)) { + if (!hasOption(options, RegistrationOption.DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION)) { static if (!is(SuperType == ConcreteType)) { auto concreteTypeRegistration = register!ConcreteType; concreteTypeRegistration.linkTo(newRegistration); @@ -160,7 +165,7 @@ synchronized class DependencyContainer { return newRegistration; } - private bool hasOption(RegistrationOptionsTuple...)(RegistrationOptionsTuple options, RegistrationOptions option) { + private bool hasOption(RegistrationOptionsTuple...)(RegistrationOptionsTuple options, RegistrationOption option) { foreach(presentOption ; options) { if (presentOption == option) { return true; diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 5df30ee..33dd555 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -435,7 +435,7 @@ version(unittest) { // Test registering type with option ADD_CONCRETE_TYPE_REGISTRATION unittest { shared(DependencyContainer) container = new DependencyContainer(); - container.register!(TestInterface, TestClass)(RegistrationOptions.ADD_CONCRETE_TYPE_REGISTRATION); + container.register!(TestInterface, TestClass)(RegistrationOption.ADD_CONCRETE_TYPE_REGISTRATION); auto firstInstance = container.resolve!TestInterface; auto secondInstance = container.resolve!TestClass; @@ -446,7 +446,7 @@ version(unittest) { // Test registering type with option DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION unittest { shared(DependencyContainer) container = new DependencyContainer(); - container.register!(TestInterface, TestClass)(RegistrationOptions.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);