From 6b82c35b2eb382a6172f28930df3292428c240be Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sun, 1 Jun 2014 22:44:02 +0200 Subject: [PATCH] Print autowirings in debug mode --- source/poodinis/autowire.d | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 7912f4e..cb0f47c 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -9,12 +9,23 @@ module poodinis.autowire; public import poodinis.container; +debug { + import std.stdio; + import std.string; +} + class Autowire{}; public void autowire(Type)(Container container, Type instance) { foreach (member ; __traits(derivedMembers, Type)) { foreach (attribute; mixin(`__traits(getAttributes, Type.` ~ member ~ `)`) ) { if (is(attribute : Autowire) && __traits(getMember, instance, member) is null){ + debug { + auto autoWireType = typeid(typeof(__traits(getMember, instance, member))); + auto memberQualifier = typeid(Type).toString(); + writeln(format("Autowire %s to %s.%s", autoWireType, memberQualifier, member)); + } + __traits(getMember, instance, member) = container.resolve!(typeof(__traits(getMember, instance, member))); } }