/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

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