Below is my parent class
public class Parent
{
//This method is intercept-able using **VirtualMethodInterceptor**
public virtual void Test()
{
//Do something
}
}
Below is my child class
public class Child:Parent
{
// This method directly not intercept-able but it calls base.Test() where Test is an intercept-able method
public void Demo(){
base.Test();
}
}
Now I want to resolve an instance of Child
class using Unity where Demo
method will be interceptable. Actually Demo
method can't be interceptable as because it's not virtual but this method internally invoke base.Test()
where Test
is intercept-able. So how to resolve an interceptable instance of Child
class?
It doesn't work If I register child class into an unity container like below
container.RegisterType<Child>(
new Interceptor<VirtualMethodInterceptor>(),
new InterceptionBehavior<Interceptor>()
)