Adding a catalog to an existing container

May 29, 2009 at 8:56 AM

Hello,

Is there any way of adding a DirectoryCatalog to a CompositionContainer other than passing it to the constructor?  I have a situation in which I have an existing container containing a 'ViewPluginLoader' MEF plugin.  From within this plugin I want to create a DirectoryCatalog of other plugins and add them to the same container.  Is this possible?

Thanks

 

Developer
May 29, 2009 at 4:31 PM

You can add an AggregateCatalog to the Container via the constructor and then later add our DirectoryCatalog to the Catalog collection of the AggregateCatalog. Something like:

var aggregate = new AggregateCatalog();
var container = new CompositionContainer(aggregate);
...
var directoryCat = new DirectoryCatalog("...");
aggregate.Catalogs.Add(directoryCat);

Jun 1, 2009 at 8:53 AM

Thanks for answering my question!