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 ComponentA componentA;
public this() { public this() {
auto container = Container.getInstance(); globalAutowire!(typeof(this))(this);
container.autowire!(typeof(this))(this);
} }
// or use: // or use:

View file

@ -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);
}