PageRenderTime 101ms CodeModel.GetById 60ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/src/LinFu.Proxy/InterfaceExtractor.cs

http://github.com/philiplaureano/LinFu
C# | 36 lines | 24 code | 3 blank | 9 comment | 5 complexity | 108f6b87cc366bddedc4c579d611da23 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using LinFu.IoC.Configuration;
 4using LinFu.Proxy.Interfaces;
 5
 6namespace LinFu.Proxy
 7{
 8    /// <summary>
 9    ///     Provides the default implementation for the
10    ///     <see cref="IExtractInterfaces" /> interface.
11    /// </summary>
12    [Implements(typeof(IExtractInterfaces), LifecycleType.OncePerRequest)]
13    public class InterfaceExtractor : IExtractInterfaces
14    {
15        /// <summary>
16        ///     Determines which interfaces a given type should implement.
17        /// </summary>
18        /// <param name="currentType">The base type that holds the list of interfaces to implement.</param>
19        /// <param name="interfaceList">The list of interfaces already being implemented. </param>
20        public void GetInterfaces(Type currentType, HashSet<Type> interfaceList)
21        {
22            var interfaces = currentType.GetInterfaces();
23            if (interfaces == null || interfaces.Length == 0)
24                return;
25
26            foreach (var current in interfaces)
27            {
28                if (interfaceList.Contains(current))
29                    continue;
30
31                interfaceList.Add(current);
32                GetInterfaces(current, interfaceList);
33            }
34        }
35    }
36}