I am currently having a problem trying to connect exactly one instance of an interceptor to one instance of a class that is intercepted.
I create and advise in InterceptorRegistrationStrategy and set a callback to resolve an interceptor from the kernel (it has an injection constructor). Please note that I can only create an interceptor in the callback because InterceptorRegistrationStrategy does not have a reference to the kernel itself.
IAdvice advice = this.AdviceFactory.Create(methodInfo);
advice.Callback = ((context) => context.Kernel.Get<MyInterceptor>());
this.AdviceRegistry.Register(advice);
I get an interceptor instance for each method.
Is there a way to create one instance of an interceptor for each instance of the instance to be intercepted?
I was thinking about Named Scope, but the intercepted type and the interceptor do not refer to each other.
source
share