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方法

}

Type Interceptors的更多相关文章

  1. Autofac 之 基于 Castle DynamicProxy2 的 Interceptor 功能

    Autofac 结合 Castle DynamicProxy2 功能        Autofac 不仅作为轻量级高效的 IoC 容器,而且还能很好的与 Castle.DynamicProxy2 结合 ...

  2. [Abp vNext 源码分析] - 3. 依赖注入与拦截器

    一.简要说明 ABP vNext 框架在使用依赖注入服务的时候,是直接使用的微软提供的 Microsoft.Extensions.DependencyInjection 包.这里与原来的 ABP 框架 ...

  3. 6. abp中的拦截器

    abp拦截器基本定义 拦截器接口定义: public interface IAbpInterceptor { void Intercept(IAbpMethodInvocation invocatio ...

  4. Castle DynamicProxy基本用法(AOP)

    本文介绍AOP编程的基本概念.Castle DynamicProxy(DP)的基本用法,使用第三方扩展实现对异步(async)的支持,结合Autofac演示如何实现AOP编程. AOP 百科中关于AO ...

  5. ASp.net Core EF ActionFilterAttribute AOP

    在项目中经常遇到一些数据的修改,很多时候业务方需要一个修改日志记录,这里我们计划用mssql数据库来存放日志记录,用EF来操作,记录日志可以用mvc的ActionFilterAttribute 来完成 ...

  6. The content of element type "package" must match "(result-types?,interceptors?...

    错误:“The content of element type "package" must match "(result-types?,interceptors?,de ...

  7. The content of element type "package" must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global- results?,global-exception-mappings?,action*)".

    报错 The content of element type "package" must match "(result-types?,interceptors?,def ...

  8. strus2配置strus.xml问题-The content of element type "package" must match "(result-types?,interceptors?

    搭建strus2项目,在配置strus.xml时候碰到了这个问题: The content of element type "package" must match "( ...

  9. 菜鸟学Struts2——Interceptors

    昨天学习Struts2的Convention plugin,今天利用Convention plugin进行Interceptor学习,虽然是使用Convention plugin进行零配置开发,这只是 ...

随机推荐

  1. 详解微信小程序支付流程

    转发博主 https://blog.csdn.net/qq_38378384/article/details/80882980 花了几天把小程序的支付模块接口写了一下,可能有着公众号开发的一点经验,没 ...

  2. [SPOJ]Count on a tree II(树上莫队)

    树上莫队模板题. 使用欧拉序将树上路径转化为普通区间. 之后莫队维护即可.不要忘记特判LCA #include<iostream> #include<cstdio> #incl ...

  3. APMServ升级PHP至5.3

    APMServ5.2.6 的php版本是php5.2.6,所以需要升级一下PHP版本:1.到 php下载地址下载PHP5.3的VC6版本的zip文件,我下载的是:php-5.3.23-Win32-VC ...

  4. Topcoder SRM656div1 250 ( 期望DP )

    Problem Statement    Charlie has N pancakes. He wants to serve some of them for breakfast. We will n ...

  5. SQL SERVER SP命令及实现跨数据库查询

    1.数据库: (1)sp_helpdb:报告有关指定数据库或所有数据库的信息. 例:sp_helpdb   --显示所有数据库信息(名称.大小等) 例:sp_helpdb Recruitment   ...

  6. 【推荐系统】知乎live入门

    参考链接: 知乎推荐系统live:姚凯飞推荐系统live 目录 1.推荐概览与框架 2.细节补充 3.召回 4.排序 5.常用技能与日常工作 5.用户画像-特征工程 6.相关经验 7.推荐考试拿分路径 ...

  7. Python之列表、元组、字典、集合及字符串的详细使用

    1.列表 列表相当与C++中的数组,是有序的项目, 通过索引进行查找,但使用起来却方便很多,具体的操作看代码,自己实践一次就非常简单了. 注:列表一般用中括号“[ ]” #列表(数组) name_li ...

  8. nodejs 报错

    vue不是内部或外部命令的解决方法 1.在nodejs的安装目录下,找到vue.cmd,将此路径加到环境变量中,我是通过nvm管理node版本的,路径是C:\Users\hy\AppData\Roam ...

  9. Jmeter接口测试---加解密

    1.加解密的jar包放到jmeter的lib/ext目录下. 项目打jar包参考https://www.cnblogs.com/fulucky/p/9436229.html 2.在测试计划---> ...

  10. AOP切面详解

    一.spring-aop.xml文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns= ...