使用新的 fluent MEF 编程模型,如果我有多个目录:
- 我要传递到哪个目录
RegistrationBuilder
??? - 我需要通过
RegistrationBuilder
调用SatisfyImportsOnce
吗? - 我使用哪个
SatisfyImportsOnce
或哪个?ComposeParts
(在流利的mef中有什么改变吗?)
例如,这是一个说明我的困惑的示例(请参阅 rhs 上的评论):
// Get pre-wired registration builder
RegistrationBuilder rb = new MefCompositionRoot().CommonRegistrationBuilder();
// Register this WCF service class
rb.ForType<LogService>().Export<LogService>();
var assembly = typeof (LogService).Assembly;
var assemblyCatalog = new AssemblyCatalog(assembly, rb); // <-- HERE?
var dirCatalog = new DirectoryCatalog("bin", rb); // <-- and HERE?
// Combine catalogs
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(dirCatalog);
catalog.Catalogs.Add(assemblyCatalog);
var container = new CompositionContainer(catalog);
container.SatisfyImportsOnce(this, rb);// THIS?
container.ComposeParsts(this); ///or THIS?