当通过不同方式发现部件的时候,还可以使用AggregateCatalog来把这些部件聚合到一起。
- AssemblyCatalog 在当前程序集发现部件。
- DirectoryCatalog 在指定的目录发现部件。
protected override void ConfigureAggregateCatalog()
{
this.AggregateCatalog.Catalogs.Add(new DirectoryCatalog(@"D:\WorkSpace_self\IOCPrism\IOCPrism\DLL"));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(IOCPrism.Shell).Assembly));
//this.Container.ComposeParts(this);
//base.ConfigureAggregateCatalog();
//var catalog = new AggregateCatalog();
//catalog.Catalogs.Add(new AssemblyCatalog(typeof(Shell).Assembly));
把从指定path发现的部件添加到目录中
//catalog.Catalogs.Add(new DirectoryCatalog(@"D:\WorkSpace_self\IOCPrism\IOCPrism\DLL"));
// DirectoryCatalog catalog = new DirectoryCatalog(@"./DLL");
// this.AggregateCatalog.Catalogs.Add(catalog);
}