Add addresses to debug info when autowiring

This commit is contained in:
Mike Bierlee 2014-06-08 15:56:24 +02:00
parent 034837d752
commit f123109a5e

View file

@ -23,13 +23,16 @@ public void autowire(Type)(Container container, Type instance) {
foreach (attribute; mixin(`__traits(getAttributes, Type.` ~ member ~ `)`) ) { foreach (attribute; mixin(`__traits(getAttributes, Type.` ~ member ~ `)`) ) {
if (is(attribute : Autowire) && __traits(getMember, instance, member) is null){ if (is(attribute : Autowire) && __traits(getMember, instance, member) is null){
alias TypeTuple!(__traits(getMember, instance, member)) memberReference; alias TypeTuple!(__traits(getMember, instance, member)) memberReference;
auto autowirableInstance = container.resolve!(typeof(memberReference));
debug { debug {
auto autoWireType = typeid(typeof(memberReference)); auto autowirableType = typeid(typeof(memberReference[0]));
auto memberQualifier = typeid(Type).toString(); auto autowireableAddress = &autowirableInstance;
writeln(format("Autowire %s to %s.%s", autoWireType, memberQualifier, member)); auto memberType = typeid(Type);
auto instanceAddress = &instance;
writeln(format("DEBUG: Autowire instance [%s@%s] to [%s@%s].%s", autowirableType, autowireableAddress, memberType, instanceAddress, member));
} }
__traits(getMember, instance, member) = container.resolve!(typeof(memberReference)); __traits(getMember, instance, member) = autowirableInstance;
} }
} }
} }