/src/LinFu.IoC/CompositePreProcessor.cs

http://github.com/philiplaureano/LinFu · C# · 34 lines · 17 code · 4 blank · 13 comment · 0 complexity · 23d04ff4681a59fa1f189af0ee85b1ec MD5 · raw file

  1. using System.Collections.Generic;
  2. using LinFu.IoC.Interfaces;
  3. namespace LinFu.IoC
  4. {
  5. /// <summary>
  6. /// Represents an <see cref="IPreProcessor" /> type that processes multiple <see cref="IPreProcessor" /> instances at
  7. /// once.
  8. /// </summary>
  9. internal class CompositePreProcessor : IPreProcessor
  10. {
  11. private readonly IEnumerable<IPreProcessor> _preProcessors;
  12. /// <summary>
  13. /// Initializes the type using the given <paramref name="preProcessors" />.
  14. /// </summary>
  15. /// <param name="preProcessors">The list of <see cref="IPreProcessor" /> instances that will be handled by this type.</param>
  16. public CompositePreProcessor(IEnumerable<IPreProcessor> preProcessors)
  17. {
  18. _preProcessors = preProcessors;
  19. }
  20. /// <summary>
  21. /// A method that passes every request result made
  22. /// to the list of preprocessors.
  23. /// </summary>
  24. /// <param name="request">The parameter that describes the context of the service request.</param>
  25. public void Preprocess(IServiceRequest request)
  26. {
  27. foreach (var preprocessor in _preProcessors) preprocessor.Preprocess(request);
  28. }
  29. }
  30. }