mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add setting persistent resolve options
This commit is contained in:
parent
a1cbd9650a
commit
5d9ac73418
|
@ -1,7 +1,7 @@
|
|||
Poodinis Changelog
|
||||
==================
|
||||
**Version NEXT**
|
||||
* ADD setting persistent registration options
|
||||
* ADD setting persistent registration and resolve options
|
||||
* DEPRECATE DO_NOT_ADD_CONCRETE_TYPE_REGISTRATION, use doNotAddConcreteTypeRegistration instead
|
||||
* DEPRECATE supplying register()'s registration options as variadic arguments. Use register(SuperType, ConcreteType)(RegistrationOption[]) instead.
|
||||
* ADD resolve options to container resolve()
|
||||
|
|
|
@ -417,7 +417,7 @@ synchronized class DependencyContainer {
|
|||
/**
|
||||
* Apply persistent registration options which will be used everytime register() is called.
|
||||
*/
|
||||
public void setPersistentRegistrationOptions(RegistrationOptionsTuple...)(RegistrationOptionsTuple registrationOptions) {
|
||||
public void setPersistentRegistrationOptions(OptionsTuple...)(OptionsTuple registrationOptions) {
|
||||
unsetPersistentRegistrationOptions();
|
||||
foreach (option; registrationOptions) {
|
||||
persistentRegistrationOptions ~= option;
|
||||
|
@ -431,4 +431,21 @@ synchronized class DependencyContainer {
|
|||
persistentRegistrationOptions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply persistent resolve options which will be used everytime resolve() is called.
|
||||
*/
|
||||
public void setPersistentResolveOptions(OptionsTuple...)(OptionsTuple resolveOptions) {
|
||||
unsetPersistentResolveOptions();
|
||||
foreach (option; resolveOptions) {
|
||||
persistentResolveOptions ~= option;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets all applied registration options
|
||||
*/
|
||||
public void unsetPersistentResolveOptions() {
|
||||
persistentResolveOptions = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -634,4 +634,19 @@ version(unittest) {
|
|||
container.resolve!(TestInterface, TestClass)([ResolveOption.registerBeforeResolving]);
|
||||
container.resolve!TestClass;
|
||||
}
|
||||
|
||||
// Test set persistent resolve options
|
||||
unittest {
|
||||
shared(DependencyContainer) container = new DependencyContainer();
|
||||
container.setPersistentResolveOptions(ResolveOption.registerBeforeResolving);
|
||||
container.resolve!TestClass;
|
||||
}
|
||||
|
||||
// Test unset persistent resolve options
|
||||
unittest {
|
||||
shared(DependencyContainer) container = new DependencyContainer();
|
||||
container.setPersistentResolveOptions(ResolveOption.registerBeforeResolving);
|
||||
container.unsetPersistentResolveOptions();
|
||||
assertThrown!ResolveException(container.resolve!TestClass);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue