c# - MEF2 - Create multiple instances with ExportFactory<> -


i have multiple dlls , i'd create new non-shared instances according parameters. something this should me creation should take parameter decide type create , want use exportfactory able dispose created instances, too.

so far have component, loads exported dlls:

regisbuilder = new registrationbuilder();  regisbuilder.fortype<wpprovider>().export<wpprovider>();  dircatalog = new directorycatalog(appdomain.currentdomain.basedirectory, regisbuilder); agrcatalog = new aggregatecatalog(dircatalog);  container = new compositioncontainer(agrcatalog, compositionoptions.disablesilentrejection); container.composeparts(); 

i think wpprovider should task exportfactory don't know how. have class:

public class wpprovider     {         exportfactory<idcplugin> _factory;          [importingconstructor]         public wpprovider(exportfactory<idcplugin> factory)         {             _factory = factory;         }          public idcplugin createinstance()         {             return _factory.createexport().value;         }     } 

the problem if have more dlls, _container.getexportedvalue(); row throws compositionexception because founds more 1 types idcplugin contract. thought exportfactory created , gives me objects when want them. way _provider ienumerable containing exports. but how behave factory?

basically need example of selecting type (or attributes) , creating multiple instances of type mef2 exportfactory , registrationbuilder.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -