Castle Windsor不拦截DataException

时间:2013-12-02 15:57:43

标签: castle-windsor

我有一个类来拦截实现IInterceptor接口的DataException,但是没有调用Intercept方法。

我正在以这种方式注册拦截器类:

container.Register(Component.For<DatabaseErrorInterceptor>().LifestyleTransient());

这是拦截器类:

public class DatabaseErrorInterceptor : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            try
            {
                invocation.Proceed();
            }
            catch (DataException exc)
            {
                throw this.MapearExcecao(excecao);
            }
        }

        private BusinessRuleException HandleException(DataException databaseError)
        {
            // ...

            return new BusinessRuleException(...);
        }
}

1 个答案:

答案 0 :(得分:0)

我们找到了这个问题的答案,它缺少对container.Kernel.ProxyFactory.AddInterceptorSelector(...)的调用;