I have a export defined as as follows in MEF preview 5
[ExportMetadata("Application", "CheckFolderApplication")]
[Export(typeof(ExtendedArtifactBase))]
public class CheckFolderArtifact2 : ExtendedArtifactBase
{ ...
Then I only want those imports with the "Application" "CheckFolderApplication" metadata. To currenly do that I read all the imports and then filter the result.
[Import(typeof(ExtendedApplicationBase))]
private ExportCollection<IApplication> _applications { get; set; }
public IApplication GetApplication(string applicationName)
{
return _applications.Single(a => a.GetExportedObject().Name == applicationName).GetExportedObject();
}
This feels really inefficient. What if I have thousands of plug-ins - do I have to read them all via MEF to just get one with the right metadata? If so how do you cache the result?