PageRenderTime 73ms CodeModel.GetById 41ms app.highlight 1ms RepoModel.GetById 30ms app.codeStats 0ms

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