Allow register by concrete type to also get registration options

Although the currently only available option will do nothing
This commit is contained in:
Mike Bierlee 2016-02-03 22:24:22 +01:00
parent 065e7111cd
commit e7a29f17f7
2 changed files with 10 additions and 2 deletions

View file

@ -98,8 +98,8 @@ synchronized class DependencyContainer {
* *
* See_Also: singleInstance, newInstance, existingInstance * See_Also: singleInstance, newInstance, existingInstance
*/ */
public Registration register(ConcreteType)() { public Registration register(ConcreteType)(RegistrationOption[] options = []) {
return register!(ConcreteType, ConcreteType)([]); return register!(ConcreteType, ConcreteType)(options);
} }
/** /**

View file

@ -511,6 +511,14 @@ version(unittest) {
auto firstInstance = container.resolve!TestInterface; auto firstInstance = container.resolve!TestInterface;
assertThrown!ResolveException(container.resolve!TestClass); assertThrown!ResolveException(container.resolve!TestClass);
} }
// Test registering conrete type with registration option doNotAddConcreteTypeRegistration does nothing
unittest {
shared(DependencyContainer) container = new DependencyContainer();
container.register!TestClass([RegistrationOption.doNotAddConcreteTypeRegistration]);
container.resolve!TestClass;
}
// Test registering type with options in the DEPRECATED way // Test registering type with options in the DEPRECATED way
unittest { unittest {
shared(DependencyContainer) container = new DependencyContainer(); shared(DependencyContainer) container = new DependencyContainer();