Return resolved instances by qualifier type instead

This commit is contained in:
Mike Bierlee 2014-12-30 18:29:32 +01:00
parent 7a628c32c4
commit 99579060d3

View file

@ -81,7 +81,7 @@ class DependencyContainer {
return resolve!(RegistrationType, RegistrationType)(); return resolve!(RegistrationType, RegistrationType)();
} }
public RegistrationType resolve(RegistrationType, QualifierType : RegistrationType)() { public QualifierType resolve(RegistrationType, QualifierType : RegistrationType)() {
TypeInfo resolveType = typeid(RegistrationType); TypeInfo resolveType = typeid(RegistrationType);
TypeInfo qualifierType = typeid(QualifierType); TypeInfo qualifierType = typeid(QualifierType);
@ -95,11 +95,11 @@ class DependencyContainer {
} }
Registration registration = getQualifiedRegistration(resolveType, qualifierType, *candidates); Registration registration = getQualifiedRegistration(resolveType, qualifierType, *candidates);
RegistrationType instance = cast(RegistrationType) registration.getInstance(); QualifierType instance = cast(QualifierType) registration.getInstance();
if (!autowireStack.canFind(registration)) { if (!autowireStack.canFind(registration)) {
autowireStack ~= registration; autowireStack ~= registration;
this.autowire!(QualifierType)(cast(QualifierType)instance); this.autowire!(QualifierType)(instance);
autowireStack.popBack(); autowireStack.popBack();
} }