Interceptors
In Castle Windsor, there is the concept of interceptors. They represent how you can implement the actual aspect and perform the cross-cutting operation.
Let’s create one for handling logging for all method calls. In the root of Chapter14, add a file called LoggingInterceptor.cs and make it look like the following:
using Castle.DynamicProxy; namespace Chapter14; public class LoggingInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { // Do something before invocation.Proceed(); // Do something after } }
The code sets up an implementation of IInterceptor from Castle Windsor. In the Intercept() method, the code calls the Proceed() method on the invocation object, which will perform the actual call it is intercepting. Before...