I'm learning to use Interceptor pattern with Ninject.
I have an interceptor as follows.
public class MyInterceptor:IInterceptor
{
public void Intercept(IInvocation invocation)
{
Console.WriteLine("Pre Execute: " + invocation.Request.Method.Name);
invocation.Proceed();
Console.WriteLine("Post Execute: " + invocation.Request.Method.Name);
Console.WriteLine("Returned: " + invocation.ReturnValue);
}
}
I'm setting up my Ninject kernel in my Main Method as follows.
kernel = new StandardKernel();
kernel.Bind<MyClass>().ToSelf().Intercept().With(new MyInterceptor());
myClass = kernel.Get<MyClass>();
Issue is that, when debugging a method call to myClass
, (I'm putting a break point on a statement like myClass.methodName()
and pressing F11) there's a LOT of stack frames to pass, before I see the call to my Interceptor, and then to the actual method call.
I do realize that Ninject creates Dynamic Proxies .etc. behind the scenes, but this makes things a little harder, If I want to see the flow of my code, from all the interceptors to the actual methods. (Imagine debugging to see which interceptor is blocking a method call)
Is there a way to tell Visual Studio not to break on Ninject stack frames ? (I don't have Ninject source with me anyway)
UPDATE Essentially, What I want to do is tell VS that don't break on code that I don't have the source for...