PageRenderTime 11ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/src/LinFu.IoC/Interceptors/ProxyContainerPlugin.cs

http://github.com/philiplaureano/LinFu
C# | 43 lines | 20 code | 5 blank | 18 comment | 0 complexity | 49e0d421cf70866ad2e07d3372e808e7 MD5 | raw file
  1. using LinFu.IoC.Configuration.Interfaces;
  2. using LinFu.IoC.Interfaces;
  3. namespace LinFu.IoC.Interceptors
  4. {
  5. /// <summary>
  6. /// A <see cref="IContainerPlugin" /> implementation that inserts
  7. /// <see cref="ProxyInjector" /> instances at the beginning of a <see cref="IServiceContainer" />
  8. /// loading sequence.
  9. /// </summary>
  10. internal class ProxyContainerPlugin : IContainerPlugin
  11. {
  12. private readonly ProxyInjector _injector;
  13. /// <summary>
  14. /// Initializes the class with the given <see cref="ProxyInjector" /> instance.
  15. /// </summary>
  16. /// <param name="injector">The postprocessor that will inject proxies in place of actual service requests.</param>
  17. internal ProxyContainerPlugin(ProxyInjector injector)
  18. {
  19. _injector = injector;
  20. }
  21. /// <summary>
  22. /// Injects a <see cref="ProxyInjector" /> into the <paramref name="target">target container</paramref>.
  23. /// </summary>
  24. /// <param name="target">The service container that will hold the <see cref="ProxyInjector" />.</param>
  25. public void BeginLoad(IServiceContainer target)
  26. {
  27. target.PostProcessors.Add(_injector);
  28. }
  29. /// <summary>
  30. /// Does absolutely nothing.
  31. /// </summary>
  32. /// <param name="target">The target container.</param>
  33. public void EndLoad(IServiceContainer target)
  34. {
  35. // Do nothing
  36. }
  37. }
  38. }