Register application contexts as a resolvable dependency

For those who like to play with fire
This commit is contained in:
Mike Bierlee 2015-12-24 20:39:42 +01:00
parent f206b594c8
commit d310640717
2 changed files with 8 additions and 0 deletions

View file

@ -373,6 +373,7 @@ synchronized class DependencyContainer {
auto context = new Context(); auto context = new Context();
context.registerDependencies(this); context.registerDependencies(this);
context.registerContextComponents(this); context.registerContextComponents(this);
this.register!(ApplicationContext, Context)().existingInstance(context);
autowire(this, context); autowire(this, context);
} }

View file

@ -589,4 +589,11 @@ version(unittest) {
assert(instance.wrapper is wrapper); assert(instance.wrapper is wrapper);
assert(instance.wrapper.someClass is someClass); assert(instance.wrapper.someClass is someClass);
} }
// Test resolving registered context
unittest {
shared(DependencyContainer) container = new DependencyContainer();
container.registerContext!TestContext;
container.resolve!ApplicationContext;
}
} }