I've got a pretty good idea how DI works in Prism when you have an IModule. However, many of my classes where I want DI are not modules, they are plain old classes. If I use the
statement, I never see any injection occur. If I use the
attribute and provide an implementation of the
interface, I get injection. I can't imagine I need to provide an
implementation on every class so what am I missing?
To illustrate the problem, I've added a simple class to the Prism 4.1 Quickstarter solution called 'ModularityWithMef.Desktop'. This class is added to the 'ModuleA' project:
public class Class1
private IModuleTracker moduleTrackerField;
public IModuleTracker ModuleTracker
this.moduleTrackerField = value;
The setter is never hit. If I decorate it with an [Export] statement, I can hit the setter, but then I get a message that I need to provide an 'Initialization()' method for any class decorated with an [Export] attribute. What am I missing here? I see the advantage
of using attribute based DI, but I can't imagine that I have to implement
on every class that uses DI.