当使用带有名称的Unity RegisterType时,Interceptor不起作用

时间:2012-04-13 03:30:04

标签: c# unity-container interception

container.RegisterType<IMyType, MyType>("MyType");

container.AddNewExtension<Interception>()
            .Configure<Interception>()
            .SetInterceptorFor<IMyType>(new InterfaceInterceptor());

当我使用名称解析我的类型时,拦截不起作用。 但是当我删除名称时,它将再次起作用。 我的代码出了什么问题?

1 个答案:

答案 0 :(得分:1)

您没有指定要使用的 InterceptionBehavior 。设置拦截器不会添加任何行为。

查看documentation on MSDN

Unity 2.0方法部分包含一个示例配置。

相关问题