【问题标题】:How would I apply an Interceptor to a list of assemblies in a directory?如何将拦截器应用于目录中的程序集列表?
【发布时间】:2012-11-22 18:20:39
【问题描述】:
例如,Mark Seemann 对此question 的回答
这是:
container.Register(AllTypes.FromAssemblyInDirectory(new AssemblyFilter(folderPath)));
这将注册给定目录中的所有程序集,包括我不感兴趣的第 3 方程序集。
我只想在一个目录中注册一个程序集列表,我不知道该怎么做的第二部分是将我的拦截器应用于该列表中的程序集。
所以我问我该怎么做?
【问题讨论】:
标签:
castle-windsor
ioc-container
castle
castle-dynamicproxy
【解决方案1】:
我不确定这是否可行,但我在想这样的事情:
foreach (var referencedAssembly in referencedAssemblies)
{
base.BootStrapContainer.Register(
Classes.FromAssemblyNamed(referencedAssembly)
.IncludeNonPublicTypes()
.Pick()
.Configure(component => component.Interceptors<TracingAspect>()));
}