Type Interceptors
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方法
}
最新文章
- json
- 弹层,iframe页面
- Android中使用反应式编程RxJava
- 如何myEclipse修改工程项目的运行环境和编译环境
- 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
- &ldquo;Sysprep 错误 + CAPI2 引起的蓝屏&rdquo;的参考解决方法
- Labeling Balls--poj3687
- 把EXCEL列号数字变成字母
- Mono+CentOS+Jexus
- salesforce零基础学习(七十七)队列的实现以及应用
- 7. ZooKeeper的stat结构
- SHELL脚本--shell数组基础
- python 模块一(random,counter,defaultdict,time,wraps,reduce) 栈 队列 双向队列
- Android UI系列-----CheckBox和RadioButton(1)
- golang:吐槽multipart的设计
- 解决gitHub下载速度慢的问题
- SSIS 事件的向上传递
- 企业IT管理说:全自动就一定是最好的吗?
- Ubuntu-18.04.2系统 Nginx+uWSGI+Django 部署生产环境
- 2017-2018-2 《网络对抗技术》 20155322 Exp3 免杀原理与实践
热门文章
- UVa 11582 Colossal Fibonacci Numbers! 紫书
- AngularJs——基础小知识(二)
- 史上最全的ORACLE基础教程
- hibernate的get方法和load方法区别
- java jdk12,安装路径没有jre文件夹
- Maven依赖项Scope属性设置含义
- BZOJ 1767] [Ceoi2009] harbingers (斜率优化)
- 搜索(BFS)---计算在网格中从原点到特定点的最短路径长度
- EL表达式多条件判断
- css3 first-of-type选择器以及css3选择器中:first-child与:first-of-type的区别