Importing parts in MEF is easy.
[ImportMany(typeof(IModule))]
public List<IModule> Modules {get; set;}
But the shell application needs to be able to provide some services to the parts.
For example the shell application has access to the datalayer, knows about authentication and authorization, etc…
Is there a simple solution. (perhaps this is really a no-brainer?) Any best practices?
Why not export these services?
If the service is bound to the shell and the shell is in charge of configuring it, then you can export it as a shell property; in which case you need to remove the export attribute from the
MyServiceclass and have this:Then each part can import and use them.
This way you know the service is configured by the shell when it’s imported.