【发布时间】:2015-11-15 04:53:40
【问题描述】:
我有许多程序集,每个程序集都通过使用扩展 Autofac.Module 的类向 Autofac 提供它们的依赖项。我将其中的每一个都装饰为 MEF 导出,例如:
[Export(typeof(IModule))]
public class ContainerModule : Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
}
}
作为客户端应用程序启动的一部分,我收集了所有这些模块,例如:
var builder = new ContainerBuilder();
var path = "Path to application Bin directory";
var catalog = new DirectoryCatalog(path, "MyApp*.dll");
builder.RegisterComposablePartCatalog(catalog);
container = builder.Build();
查看目录时,我可以看到所有组件中的所有模块都存在。
我的问题是如何指示 Autofac 在每个加载的模块上调用 Load 方法?
我正在考虑 builder.RegisterAssemblyModules 的一些用法,但还没有(还)知道如何将其与目录联系起来。
谢谢!
r.
【问题讨论】:
标签: mef autofac autofac-module