Add global autowire function

This commit is contained in:
Mike Bierlee 2014-07-04 02:42:55 +02:00
parent 7dbf5ace61
commit edb39c6d54
2 changed files with 50 additions and 48 deletions

View file

@ -133,8 +133,7 @@ class ComponentF {
public ComponentA componentA;
public this() {
auto container = Container.getInstance();
container.autowire!(typeof(this))(this);
globalAutowire!(typeof(this))(this);
}
// or use:

View file

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