2011-11-29 81 views
2

我有一个工具需要注册一个拦截器,然后将这个拦截器注册到 已注册到容器Castle Kernel中的子集。城堡中的组件注册后注册拦截器

该设施住在separatee组件和它的目的是从不同的 组件中使用,所以我不能夫妇与组件注册使用该设施的每个组件的 拦截器注册。

可以做到这一点吗? 我该如何实现此功能?

回答

1

通常我使用设施的方法是这样的:

// 1. create the container 
var container = new WindsorContainer(); 

// 2. add all the facilities I need 
container.AddFacility<SomeFacility>(); 
contianer.AddFacility<SomeOtherFacility>(); 

// 3. install all the components 
container.Install(FromAssembly.This()); 

这些设施通常要么订阅container events,注册了自己的一些成分,或添加ComponentModel construction contributors是检查和加强部件ComponentModel被注册。

这样它可以完全透明的组件和施加组件和设施之间的显式耦合(除非你想要它)。

+0

谢谢你,我只是发现贡献者。我不知道他们存在! – angrifel