Reduce code due to type deduction

This commit is contained in:
Mike Bierlee 2014-07-10 01:09:36 +02:00
parent b38bccc03c
commit 5caf57d31d
2 changed files with 4 additions and 4 deletions

View file

@ -104,7 +104,7 @@ class ExampleClassB {
container.register!ExampleClassA;
auto exampleInstance = new ExampleClassB();
container.autowire!ExampleClassB(exampleInstance);
container.autowire(exampleInstance);
assert(exampleInstance.dependency !is null);
```
At the moment, it is only possible to autowire public members or properties.
@ -133,7 +133,7 @@ class ComponentF {
public ComponentA componentA;
public this() {
globalAutowire!(typeof(this))(this);
globalAutowire(this);
}
// or use:

View file

@ -42,10 +42,10 @@ public void autowire(Type)(Container container, Type instance) {
mixin template AutowireConstructor() {
public this() {
globalAutowire!(typeof(this))(this);
globalAutowire(this);
}
}
public void globalAutowire(Type)(Type instance) {
Container.getInstance().autowire!(typeof(instance))(instance);
Container.getInstance().autowire(instance);
}