Reputation: 1391
I would like to build an extensible NET application using MEF. This works very well for discovering and injecting instances of new types in my application. The problem I have is that some API I am using does not permit injecting new objects, but instead receives as input the type for those plugged in objects which is obviously unknown compile time. Of course I can resolve the type of an object at run time in my code but in order for the API to work I would also have to load the assembly containing the plugins, a step which is obviously not performed in a typical MEF application. I could do that at runtime by scanning the directory where new plugins will be dumped and load those dll-s but this does not feel very MEFy anymore .. Is there some other way? Thanks.
Upvotes: 2
Views: 128
Reputation: 66733
I could do that at runtime by scanning the directory where new plugins will be dumped and load those dll-s but this does not feel very MEFy anymore .. Is there some other way?
Normally you use MEF to compose objects, not to find types.
But MEF does implement what you describe in the DirectoryCatalog. You can enumerate parts exported with MEF attributes with the DirectoryCatalog.Parts
property.
Upvotes: 3