0
如何注册一个没有使用Autofac实现的界面?如何注册一个没有autofac实现的接口?
我想Autofac使用DynamicProxy生成界面你我!
builder.RegisterType(typeof(IUserDao))
.AsImplementedInterfaces()
.EnableInterfaceInterceptors()
.InterceptedBy(typeof(SqlMapperInterceptor));
public class SqlMapperInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
//todo: mapper sql file and return data
}
}
哈瓦任何其他方式我不t想要impl空对象类,我可以使用Castle.DynamicProxy的CreateInterfaceProxyWithoutTarget,但我不知道如何使用Autofac.Extras.DynamicProxy做到这一点。 'ProxyGenerator proxyGen = new ProxyGenerator(); var userDaoProxy = proxyGen.CreateInterfaceProxyWithoutTarget(new SqlMapperInterceptor());' –
user3187103