I read all the questions that I can find regarding import creation issues without exporting the containing class, but I cannot find a solution to my problem. Does anyone know a way to achieve what I'm trying to do?
My modular builds have the forms and classes that they use internally. These forms need access to some exported contracts, but the import does not load because they are not in the MEF composition tree
Host assembly:
public class Host
{
public Host()
{ }
[Export(typeof(Licence))]
public Licence LoadedLicence { get; set; }
[Export(typeof(IModule))]
public List<IModule> LoadedModules { get; set; }
}
Build module:
[Export(typeof(IModule))]
public class Module : IModule
{
public Module() { }
public void DoSomething()
{
SubForm sub = new SubForm();
sub.ShowDialog();
}
[Import(typeof(Licence))]
public Licence LoadedLicence { get; set; }
}
public class SubForm : Form
{
public SubForm ()
{ }
[Import(typeof(Licence))]
public Licence LoadedLicence { get; set; }
}
As far as I can tell, my options are:
- Passing parameters to designers (pain)
- Use dummy export for classes requiring imports that satisfy?
Any others?
source
share