From 771c49d86adeb26021c5ed737973f732b9eeafed Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Mon, 27 Jun 2016 20:55:07 +0200 Subject: [PATCH] Deprecate array-based assignment of persistent resolve/registration options --- source/poodinis/container.d | 15 +++++++++++---- test/poodinis/containertest.d | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 9ed4b89..6576b88 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -447,12 +447,16 @@ synchronized class DependencyContainer { /** * Apply persistent registration options which will be used everytime register() is called. + * + * Deprecated: use setPersistentRegistrationOptions(RegistrationOption options) instead. */ - public void setPersistentRegistrationOptions(RegistrationOption[] registrationOptions...) { + deprecated public void setPersistentRegistrationOptions(RegistrationOption[] registrationOptions...) { persistentRegistrationOptions = buildFlags(registrationOptions); } - /// ditto + /** + * Apply persistent registration options which will be used everytime register() is called. + */ public void setPersistentRegistrationOptions(RegistrationOption options) { persistentRegistrationOptions = options; } @@ -466,12 +470,15 @@ synchronized class DependencyContainer { /** * Apply persistent resolve options which will be used everytime resolve() is called. + * Deprecated: use setPersistentResolveOptions(ResolveOption options) instead. */ - public void setPersistentResolveOptions(ResolveOption[] resolveOptions...) { + deprecated public void setPersistentResolveOptions(ResolveOption[] resolveOptions...) { persistentResolveOptions = buildFlags(resolveOptions); } - /// ditto + /** + * Apply persistent resolve options which will be used everytime resolve() is called. + */ public void setPersistentResolveOptions(ResolveOption options) { persistentResolveOptions = options; } diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 7fbbf0f..643fefa 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -628,6 +628,14 @@ version(unittest) { assertThrown!ResolveException(container.resolve!TestClass); } + // Test set persistent registration options by variadic (DEPRECATED) + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.setPersistentRegistrationOptions(RegistrationOption.none, RegistrationOption.doNotAddConcreteTypeRegistration); + container.register!(TestInterface, TestClass); + assertThrown!ResolveException(container.resolve!TestClass); + } + // Test unset persistent registration options unittest { shared(DependencyContainer) container = new DependencyContainer(); @@ -651,6 +659,13 @@ version(unittest) { container.resolve!TestClass; } + // Test set persistent resolve options by variadic (DEPRECATED) + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.setPersistentResolveOptions(ResolveOption.none, ResolveOption.registerBeforeResolving); + container.resolve!TestClass; + } + // Test unset persistent resolve options unittest { shared(DependencyContainer) container = new DependencyContainer();