我正在尝试为我的应用程序设置异常处理块,并希望在我的 IoC 工厂中注册模块和统一拦截时注入异常处理策略(在配置文件中定义)。
现在我只是注册类型并设置拦截并使用如下异常行为:
container.AddNewExtension<Interception>();
container.RegisterType<INotificationService, NotificationService>(
new TransientLifetimeManager(), new Interceptor<InterfaceInterceptor>(),
new InterceptionBehavior<ExceptionBehavior>());
然后我在我的异常行为的 Invoke 方法中处理异常并在那里应用这样的策略:
exManager.HandleException(ex, policy);
这是正确的方法吗?有任何想法或反馈吗?在设置统一容器时如何注入策略?