/src/LinFu.AOP.Interfaces/CountingInterceptor.cs

http://github.com/philiplaureano/LinFu · C# · 25 lines · 20 code · 5 blank · 0 comment · 0 complexity · 260c97ea383b72f85cd6f0f668bc375d MD5 · raw file

  1. namespace LinFu.AOP.Interfaces
  2. {
  3. internal class CountingInterceptor : IInterceptor
  4. {
  5. private readonly ICallCounter _callCounter;
  6. private readonly IInterceptor _methodReplacement;
  7. internal CountingInterceptor(ICallCounter callCounter, IInterceptor methodReplacement)
  8. {
  9. _callCounter = callCounter;
  10. _methodReplacement = methodReplacement;
  11. }
  12. public object Intercept(IInvocationInfo info)
  13. {
  14. _callCounter.Increment(info);
  15. var returnValue = _methodReplacement.Intercept(info);
  16. _callCounter.Decrement(info);
  17. return returnValue;
  18. }
  19. }
  20. }