I've been trying to use MEF within my applications and it's been awesome, so far. Right now, I am trying to understand how to do constructor dependency injection and I'm lost.
Let's say, I created a class called
and another class called
. I use the config service to bring down some values that is required within the constructor of the
public Clinic([Import(typeof(IConfigService))] IConfigService configService)
if (configService != null)
Settings = new ConfigSettings(configService.GetSettings());
That's the constructor of the
and below is the export of the
class ConfigSettingsService : IConfigService
I have catalog defined in the App.xaml and I know if I created a property to import the an instance of
, things would work smoothly.
My question is that, if I want to manually create an instance of
Clinic in a different class (i.e. a class other than App.xaml and it's instance is not instantiated by MEF) in which I don't have a catalog. How can I do that?
I hope I explained the question well and please, let me know if further clarifications are needed