Is Export required?

Jul 21, 2009 at 4:03 PM

In my limited testing, I haven't been able to Import something that wasn't explicitly Exported.  Is there a way to say "Import anything that implements the ICanDoIt interface"?  If not, why?  Being able to import an interface that was not marked with [Export] would enable people to create plug-ins that did not reference or depend on MEF.

 

Coordinator
Jul 21, 2009 at 5:59 PM

If you can modify the ICanDoIt interface, you can put an InheritedExportAttribute on it:

[InheritedExport]
public interface ICanDoIt { /* ... */ }

If you can't put the attribute on ICanDoIt, then there isn't a way to do this (without writing your own programming model).

Thanks,
Daniel