Why does Unity use injection behavior when resolving a class registered as an implementation of some interface

I register the dependency as follows:

this.Container.RegisterType<IFoo, Foo>(
    new ContainerControlledLifetimeManager(),
    new InterceptionBehavior<PolicyInjectionBehavior>(), new Interceptor<InterfaceInterceptor>());

this works great. However, when I resolve Fooinstead IFoo, I get an error:

ArgumentException - the passed type must be an interface.

It seems Unity is still trying to apply InterfaceInterceptorto this dependency. But why?

+4
source share

Source: https://habr.com/ru/post/1667359/


All Articles