Type Interceptors

Castle.Core, part of the Castle Project, provides a method interception framework called “DynamicProxy.”

The Autofac.Extras.DynamicProxy integration package enables method calls on Autofac components to be intercepted by other components. Common use-cases are transaction handling, logging, and declarative security. You can use Autofac.Extras.DynamicProxy2 for Autofac versions up to 4.0.0

builder.RegisterType<AdminWebProxyObject>().As<IAdminWebContract>().InstancePerLifetimeScope().EnableInterfaceInterceptors().InterceptedBy(typeof(BoAuditTraceInterceptor));

关于循环引用的问题

手动new的接口的实现类的实例,然后调用方法,不会触发intercept

假设有接口IA和一个IInterceptor的实现ChuckIntercept。

IA的实现通过autofac进行解析,在一个静态类B中。

interface IA

{

string GetConnectionString();

}

class A : IA

{

}

class  B

{

public static IA InstanceA; //autofac负责resolve

}

ChuckIntercept : IIntercept

{

//如果在这里需要用到A里面的GetConnectionString方法

只能自己在这边new一个A的实例,不可以使用autofac的解析,否则会循环触发intercept方法

}

最新文章

  1. json
  2. 弹层,iframe页面
  3. Android中使用反应式编程RxJava
  4. 如何myEclipse修改工程项目的运行环境和编译环境
  5. 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
  6. &ldquo;Sysprep 错误 + CAPI2 引起的蓝屏&rdquo;的参考解决方法
  7. Labeling Balls--poj3687
  8. 把EXCEL列号数字变成字母
  9. Mono+CentOS+Jexus
  10. salesforce零基础学习(七十七)队列的实现以及应用
  11. 7. ZooKeeper的stat结构
  12. SHELL脚本--shell数组基础
  13. python 模块一(random,counter,defaultdict,time,wraps,reduce) 栈 队列 双向队列
  14. Android UI系列-----CheckBox和RadioButton(1)
  15. golang:吐槽multipart的设计
  16. 解决gitHub下载速度慢的问题
  17. SSIS 事件的向上传递
  18. 企业IT管理说:全自动就一定是最好的吗?
  19. Ubuntu-18.04.2系统 Nginx+uWSGI+Django 部署生产环境
  20. 2017-2018-2 《网络对抗技术》 20155322 Exp3 免杀原理与实践

热门文章

  1. UVa 11582 Colossal Fibonacci Numbers! 紫书
  2. AngularJs——基础小知识(二)
  3. 史上最全的ORACLE基础教程
  4. hibernate的get方法和load方法区别
  5. java jdk12,安装路径没有jre文件夹
  6. Maven依赖项Scope属性设置含义
  7. BZOJ 1767] [Ceoi2009] harbingers (斜率优化)
  8. 搜索(BFS)---计算在网格中从原点到特定点的最短路径长度
  9. EL表达式多条件判断
  10. css3 first-of-type选择器以及css3选择器中:first-child与:first-of-type的区别