/Rhino.Etl.Core/Operations/BranchingOperation.cs

http://github.com/ayende/rhino-etl · C# · 40 lines · 25 code · 6 blank · 9 comment · 2 complexity · 12c75e32b84f305c7c9a01efdd49ac63 MD5 · raw file

  1. using System.Linq;
  2. using Rhino.Etl.Core.Enumerables;
  3. namespace Rhino.Etl.Core.Operations
  4. {
  5. using System.Collections.Generic;
  6. /// <summary>
  7. /// Branch the current pipeline flow into all its inputs
  8. /// </summary>
  9. public class BranchingOperation : AbstractBranchingOperation
  10. {
  11. /// <summary>
  12. /// Executes this operation, sending the input of this operation
  13. /// to all its child operations
  14. /// </summary>
  15. /// <param name="rows">The rows.</param>
  16. /// <returns></returns>
  17. public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
  18. {
  19. var copiedRows = new CachingEnumerable<Row>(rows);
  20. foreach (IOperation operation in Operations)
  21. {
  22. var cloned = copiedRows.Select(r => r.Clone());
  23. IEnumerable<Row> enumerable = operation.Execute(cloned);
  24. if(enumerable==null)
  25. continue;
  26. IEnumerator<Row> enumerator = enumerable.GetEnumerator();
  27. #pragma warning disable 642
  28. while (enumerator.MoveNext()) ;
  29. #pragma warning restore 642
  30. }
  31. yield break;
  32. }
  33. }
  34. }