From d3106407178346ba9f495cd10e837c950eba96e7 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Thu, 24 Dec 2015 20:39:42 +0100 Subject: [PATCH] Register application contexts as a resolvable dependency For those who like to play with fire --- source/poodinis/container.d | 1 + test/poodinis/containertest.d | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 61037a3..49651a7 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -373,6 +373,7 @@ synchronized class DependencyContainer { auto context = new Context(); context.registerDependencies(this); context.registerContextComponents(this); + this.register!(ApplicationContext, Context)().existingInstance(context); autowire(this, context); } diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 61490fb..67d7e52 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -589,4 +589,11 @@ version(unittest) { assert(instance.wrapper is wrapper); assert(instance.wrapper.someClass is someClass); } + + // Test resolving registered context + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.registerContext!TestContext; + container.resolve!ApplicationContext; + } }