I think the following should achieve what you're after
Define a UnityContainerExtension
like so:
public class InterceptionExtension : UnityContainerExtension
{
protected override void Initialize()
{
Context.Registering += OnRegister;
Context.RegisteringInstance += OnRegisterInstance;
}
public override void Remove()
{
Context.Registering -= OnRegister;
Context.RegisteringInstance -= OnRegisterInstance;
}
private void OnRegister(object sender, RegisterEventArgs e)
{
Container.Configure<Interception>()
.SetInterceptorFor(e.TypeTo, new VirtualMethodInterceptor());
}
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e)
{
Container.Configure<Interception>()
.SetInterceptorFor(e.RegisteredType, new VirtualMethodInterceptor());
}
}
Add this to the container:
_container.AddNewExtension<InterceptionExtension>();
Then for every registered type, this should configure Interception
to apply on virtual members. This should then pick up on any applied [HandlerAttribute]
s.