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;
|
container.register!ExampleClassA;
|
||||||
auto exampleInstance = new ExampleClassB();
|
auto exampleInstance = new ExampleClassB();
|
||||||
container.autowire!ExampleClassB(exampleInstance);
|
container.autowire(exampleInstance);
|
||||||
assert(exampleInstance.dependency !is null);
|
assert(exampleInstance.dependency !is null);
|
||||||
```
|
```
|
||||||
At the moment, it is only possible to autowire public members or properties.
|
At the moment, it is only possible to autowire public members or properties.
|
||||||
|
@ -133,7 +133,7 @@ class ComponentF {
|
||||||
public ComponentA componentA;
|
public ComponentA componentA;
|
||||||
|
|
||||||
public this() {
|
public this() {
|
||||||
globalAutowire!(typeof(this))(this);
|
globalAutowire(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// or use:
|
// or use:
|
||||||
|
|
|
@ -42,10 +42,10 @@ public void autowire(Type)(Container container, Type instance) {
|
||||||
|
|
||||||
mixin template AutowireConstructor() {
|
mixin template AutowireConstructor() {
|
||||||
public this() {
|
public this() {
|
||||||
globalAutowire!(typeof(this))(this);
|
globalAutowire(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void globalAutowire(Type)(Type instance) {
|
public void globalAutowire(Type)(Type instance) {
|
||||||
Container.getInstance().autowire!(typeof(instance))(instance);
|
Container.getInstance().autowire(instance);
|
||||||
}
|
}
|
Loading…
Reference in a new issue