mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add registeration of context components when registering via dependency container
This commit is contained in:
parent
57b548aeae
commit
2e4c688ab2
|
@ -372,6 +372,7 @@ synchronized class DependencyContainer {
|
||||||
public void registerContext(Context : ApplicationContext)() {
|
public void registerContext(Context : ApplicationContext)() {
|
||||||
auto context = new Context();
|
auto context = new Context();
|
||||||
context.registerDependencies(this);
|
context.registerDependencies(this);
|
||||||
|
context.registerContextComponents(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,11 @@ version(unittest) {
|
||||||
public override void registerDependencies(shared(DependencyContainer) container) {
|
public override void registerDependencies(shared(DependencyContainer) container) {
|
||||||
container.register!TestClass;
|
container.register!TestClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public UnrelatedClass unrelated() {
|
||||||
|
return new UnrelatedClass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TestInterface {
|
interface TestInterface {
|
||||||
|
@ -500,4 +505,13 @@ version(unittest) {
|
||||||
|
|
||||||
assert(instance !is null);
|
assert(instance !is null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test resolving dependency from registered application context
|
||||||
|
unittest {
|
||||||
|
shared(DependencyContainer) container = new DependencyContainer();
|
||||||
|
container.registerContext!TestContext;
|
||||||
|
auto instance = container.resolve!UnrelatedClass;
|
||||||
|
|
||||||
|
assert(instance !is null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue