I am trying to have a cross cutting concern intercept my calls on my controller but for some reason they aren't being intercepted.
I am basically trying to get the example here to work: http://simpleinjector.readthedocs.org/en/latest/InterceptionExtensions.html
They have some other info in the interception section here too: http://simpleinjector.readthedocs.org/en/latest/advanced.html
I have a feeling it is because I am not setting up the Container correctly. Could someone show me how I need to change my main to see "Intercepted!!!"
after the calls on the Controller are made? Also, can someone tell me if the setup for the Container was wrong, and if so, explain my error(s).
The Code:
static void Main()
{
Console.WriteLine("Start");
RedisController2 redisController = new RedisController2();
Container _container = new Container();
_container.InterceptWith<MonitoringInterceptor>(type => type == typeof(IRedisController2));
_container.RegisterSingle<MonitoringInterceptor>();
redisController.PrintSomething();
redisController.PrintOther();
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
internal class MonitoringInterceptor : IInterceptor
{
public MonitoringInterceptor()
{
}
public void Intercept(IInvocation invocation)
{
invocation.Proceed();
//var decoratedType = invocation.InvocationTarget.GetType();
Console.Write("Intercepted!!!");
Console.ReadKey();
}
}