Is it possible to intercept an IInvocation using dynamic proxy and windsor (if windsor is even needed for such a case. I am using it to configure the proxy generation though)?
I would like to log that an interception has changed the call to the intercepted method.
For example the passed arguments were changed or the return value.
Note that this is for debug only purposes.
Asked
Active
Viewed 1,658 times
0

the_drow
- 18,571
- 25
- 126
- 193
2 Answers
0
Follow the code below:
public class TransactionInterceptor : IInterceptor
{
private readonly IUnitOfWork _UnitOfWork;
public TransactionInterceptor(IUnitOfWork unitOfWork)
{
_UnitOfWork = unitOfWork;
}
public void Intercept(IInvocation invocation)
{
_UnitOfWork.Begin();
try
{
invocation.Proceed();
_UnitOfWork.Commit();
}
catch (Exception)
{
_UnitOfWork.RollBack();
throw;
}
}
}

Mohammad Almasi
- 400
- 6
- 19
-2
Yes, its possible, I recommend to read this

Chen Kinnrot
- 20,609
- 17
- 79
- 141
-
1Your answer doesn't explain how and refers to a very very general tutorial. Your answer is very similar to some guy that paste http://msdn.microsoft.com as an answer to a specific C# question. **Read my question again**. – the_drow May 08 '11 at 13:21