【问题标题】:Castle Windsor not intercepting DataException温莎城堡没有拦截 DataException
【发布时间】:2013-12-03 23:17:03
【问题描述】:

我有一个类来拦截实现 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(...);
        }
}

【问题讨论】:

  • 如何注册异常?没有异常的接口。
  • 您需要在您的数据库服务上调用 Interceptors() 以便调用拦截器,您不必注册异常
  • 仍然无法使用代码:container.Register(Component.For(typeof(ICommand)).Interceptors());

标签: castle-windsor


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    相关资源
    最近更新 更多