Is it possible to mark an interface for export, so that all derived classes will be available for import?
[Export( typeof( IMyInterface ) )]
public interface IMyInterface { ... }
[Import( typeof( IMyInterface ) )]
private readonly ICollection<IMyInterface> m_Concretes = new Collection<IPlugin>();
I don't know which classes are implementing IMyInterface
in this example. The classes themselves do not know anything about MEF - and do not use the [Export]
attribute.
As long as I do not mark every single class with [Export]
it doesn't seem to work for me.
In the current preview, you can try putting a [PartExportsInherited] attribute on the interface (along with the Export attribute). I'm not sure whether this will work for interfaces or not, though.
We do plan to add support to putting exports on interfaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With