Deprecate array-based assignment of persistent resolve/registration options

This commit is contained in:
Mike Bierlee 2016-06-27 20:55:07 +02:00
parent f67e67b93c
commit 771c49d86a
2 changed files with 26 additions and 4 deletions

View file

@ -447,12 +447,16 @@ synchronized class DependencyContainer {
/** /**
* Apply persistent registration options which will be used everytime register() is called. * 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); persistentRegistrationOptions = buildFlags(registrationOptions);
} }
/// ditto /**
* Apply persistent registration options which will be used everytime register() is called.
*/
public void setPersistentRegistrationOptions(RegistrationOption options) { public void setPersistentRegistrationOptions(RegistrationOption options) {
persistentRegistrationOptions = options; persistentRegistrationOptions = options;
} }
@ -466,12 +470,15 @@ synchronized class DependencyContainer {
/** /**
* Apply persistent resolve options which will be used everytime resolve() is called. * 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); persistentResolveOptions = buildFlags(resolveOptions);
} }
/// ditto /**
* Apply persistent resolve options which will be used everytime resolve() is called.
*/
public void setPersistentResolveOptions(ResolveOption options) { public void setPersistentResolveOptions(ResolveOption options) {
persistentResolveOptions = options; persistentResolveOptions = options;
} }

View file

@ -628,6 +628,14 @@ version(unittest) {
assertThrown!ResolveException(container.resolve!TestClass); 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 // Test unset persistent registration options
unittest { unittest {
shared(DependencyContainer) container = new DependencyContainer(); shared(DependencyContainer) container = new DependencyContainer();
@ -651,6 +659,13 @@ version(unittest) {
container.resolve!TestClass; 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 // Test unset persistent resolve options
unittest { unittest {
shared(DependencyContainer) container = new DependencyContainer(); shared(DependencyContainer) container = new DependencyContainer();