【发布时间】: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