【问题标题】:Setup Exception Handling Application Block via Unity Interception and inject exception policies通过 Unity 拦截设置异常处理应用程序块并注入异常策略
【发布时间】:2011-10-28 13:08:55
【问题描述】:

我正在尝试为我的应用程序设置异常处理块并希望 在该点注入异常处理策略(在配置文件中定义) 我在我的 IoC 工厂中统一注册模块和拦截。

现在我只是注册类型并设置拦截并使用如下异常行为:

container.AddNewExtension<Interception>();
container.RegisterType<INotificationService, NotificationService>(
     new TransientLifetimeManager(), new Interceptor<InterfaceInterceptor>(),
     new InterceptionBehavior<ExceptionBehavior>());

然后我在我的异常行为的 Invoke 方法中处理异常并在那里应用这样的策略:

exManager.HandleException(ex, policy);

这是正确的方法吗?有任何想法或反馈吗?我该如何注入政策? 设置统一容器?

【问题讨论】:

标签: c# .net exception-handling enterprise-library unity2.0


【解决方案1】:

您可以使用 Enterprise 库中的策略注入功能并使用异常处理处理程序:https://msdn.microsoft.com/en-us/library/Ff660909%28v=PandP.20%29.aspx

【讨论】:

    猜你喜欢
    • 2012-07-05
    • 1970-01-01
    • 2018-07-24
    • 2011-01-23
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    • 2012-02-16
    • 2016-02-14
    相关资源
    最近更新 更多