mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add global autowire function
This commit is contained in:
parent
7dbf5ace61
commit
edb39c6d54
|
@ -133,8 +133,7 @@ class ComponentF {
|
||||||
public ComponentA componentA;
|
public ComponentA componentA;
|
||||||
|
|
||||||
public this() {
|
public this() {
|
||||||
auto container = Container.getInstance();
|
globalAutowire!(typeof(this))(this);
|
||||||
container.autowire!(typeof(this))(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// or use:
|
// or use:
|
||||||
|
|
|
@ -40,7 +40,10 @@ public void autowire(Type)(Container container, Type instance) {
|
||||||
|
|
||||||
mixin template AutowireConstructor() {
|
mixin template AutowireConstructor() {
|
||||||
public this() {
|
public this() {
|
||||||
auto __container = Container.getInstance();
|
globalAutowire!(typeof(this))(this);
|
||||||
__container.autowire!(typeof(this))(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void globalAutowire(Type)(Type instance) {
|
||||||
|
Container.getInstance().autowire!(typeof(instance))(instance);
|
||||||
|
}
|
Loading…
Reference in a new issue