gpt4 book ai didi

c# - 在 CaSTLe 中注册组件后注册拦截器

转载 作者:太空宇宙 更新时间:2023-11-03 14:09:20 24 4
gpt4 key购买 nike

我有一个设施需要注册一个拦截器,然后将这个拦截器注册到已在容器 CaSTLe Kernel 中注册的组件子集。

该设施位于一个单独的组件中,旨在从不同的地方使用程序集,所以我不能将拦截器注册与组件注册结合起来 使用此设施的每个程序集。

这有可能吗?我怎样才能实现这个功能?

最佳答案

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

// 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

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

关于c# - 在 CaSTLe 中注册组件后注册拦截器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8316033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com