PageRenderTime 182ms CodeModel.GetById 80ms app.highlight 2ms RepoModel.GetById 99ms app.codeStats 0ms

/src/LinFu.AOP.Interfaces/CompositeAroundInvoke.cs

http://github.com/philiplaureano/LinFu
C# | 36 lines | 28 code | 7 blank | 1 comment | 4 complexity | fe422c49c7630d5604215b0fe6943334 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3
 4namespace LinFu.AOP.Interfaces
 5{
 6    internal class CompositeAroundInvoke : IAroundInvoke
 7    {
 8        private readonly IList<IAroundInvoke> _aroundInvokeList = new List<IAroundInvoke>();
 9
10        public CompositeAroundInvoke(IEnumerable<IAroundInvoke> aroundInvokeList)
11        {
12            if (aroundInvokeList == null)
13                throw new ArgumentNullException("aroundInvokeList");
14
15            // Filter out the null values
16            foreach (var current in aroundInvokeList)
17            {
18                if (current == null)
19                    continue;
20
21                _aroundInvokeList.Add(current);
22            }
23        }
24
25
26        public void AfterInvoke(IInvocationInfo context, object returnValue)
27        {
28            foreach (var invoke in _aroundInvokeList) invoke.AfterInvoke(context, returnValue);
29        }
30
31        public void BeforeInvoke(IInvocationInfo context)
32        {
33            foreach (var invoke in _aroundInvokeList) invoke.BeforeInvoke(context);
34        }
35    }
36}