I am trying to setup Exception Handling Block for my application and would like to inject exception handling policies (defined in configuration file) at the point where I am registering modules and interception with unity in my IoC factory.
现在,我只是登记各种类型,确定拦截和使用例外行为,例如:
container.AddNewExtension<Interception>();
container.RegisterType<INotificationService, NotificationService>(
new TransientLifetimeManager(), new Interceptor<InterfaceInterceptor>(),
new InterceptionBehavior<ExceptionBehavior>());
Then I am handling exception in the Invoke method of my exception behaviour and applying policies there like this:
exManager.HandleException(ex, policy);
Is this the right way and any ideas or feedback and how can I inject policies when I am setting up the unity container?