mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Reduce code due to type deduction
This commit is contained in:
parent
b38bccc03c
commit
5caf57d31d
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue