我的 global.axax 中有代码:
protected void Application_Start()
{
WindsorContainer = new WindsorContainer();
WindsorContainer.Install(FromAssembly.InDirectory(new AssemblyFilter(AppDomain.CurrentDomain.RelativeSearchPath)));
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(WindsorContainer.Kernel));
//...
}
当我调试 global.asax 时,代码FromAssembly.InDirectory(newAssemblyFilter(AppDomain.CurrentDomain.RelativeSearchPath))
会找到我所有的项目 dll(有 7 个 dll)。其中3个包含IWindsorInstaller
接口的实现,例如:
class WindsorInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
var services = AllTypes.FromThisAssembly().Where(type => type.Name.EndsWith("Service"));
container.Register(services
.WithService.DefaultInterfaces()
.Configure(c => c.LifestyleTransient()));
container.Register(Component.For<ISession>().ImplementedBy<AspnetSession>().
LifeStyle.Transient);
container.Register(Component.For<ICache>().ImplementedBy<AspnetCache>().
LifeStyle.Transient);
}
}
但是当我设置断点时,只调用了 1 个安装程序,跳过了 2 个其他安装程序。这很有趣,但我有另一个工作项目来自我复制的代码。