Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (34 sloc) 1.09 KB
using SimpleConsoleApplication.Interfaces;
namespace SimpleConsoleApplication.Interceptors
{
/// <summary>
/// Base class for custom interceptors
/// </summary>
public abstract class CustomBaseInterceptor : IInterceptor
{
protected readonly ILogger Logger;
/// <summary>
/// Using constructor injection on the interceptor
/// </summary>
/// <param name="logger">Logger</param>
protected CustomBaseInterceptor(ILogger logger)
{
Logger = logger;
}
/// <summary>
/// Pre procced action method
/// </summary>
protected virtual void PreProceedAction(IInvocation invocation) { }
/// <summary>
/// Post procced action method
/// </summary>
protected virtual void PostProceedAction(IInvocation invocation) { }
public void Intercept(IInvocation invocation)
{
PreProceedAction(invocation);
// Calls the decorated instance.
invocation.Proceed();
PostProceedAction(invocation);
}
}
}