I have a MEF CompositionContainer, a contract (say IFoo), and a module (Prism module, but here it doesn't really matter, just some kind of component). I want the contract implementation (FooImpl) to be registered in my module.
If it is Unity, I would do the following:
unity.RegisterType<IFoo, FooImpl>().
It's all. With MEF I'm puzzled. I should mention my implementation of ExportAttribute, but this will lead to its automatic export. I want to deal with this myself. Take a look at the code:
class MyModule: IModule {
private CompositionContainer m_container;
public MyModule(CompositionContainer container) {
m_container = container;
}
public void Initialize() {
??? I want something like m_container.CreateExport<IFoo, FooImpl>()
}
}
public interface IFoo {}
public class FooImpl : IFoo {
public FooImpl(ISomeService svc) {}
}
Initialize FooImpl IFoo, ExportAttribute FooImpl.
, FooImpl ( MyModule.Initialize ),
FooImpl /, , .
, , : CompositionContainer ? , ImportingConstructorAttribute?