Skip to content

Instantly share code, notes, and snippets.

@jermdavis
Created October 26, 2016 11:17
Show Gist options
  • Save jermdavis/5696495f7bff467fc8039e35a4f218de to your computer and use it in GitHub Desktop.
Save jermdavis/5696495f7bff467fc8039e35a4f218de to your computer and use it in GitHub Desktop.
A possible looped pipeline step for processing IEnumerable<> inputs
using System.Collections.Generic;
namespace StronglyTypedPipelines
{
public class LoopStep<INPUT,OUTPUT> : IPipelineStep<IEnumerable<INPUT>, IEnumerable<OUTPUT>>
{
private IPipelineStep<INPUT, OUTPUT> _internalStep;
public LoopStep(IPipelineStep<INPUT, OUTPUT> internalStep)
{
_internalStep = internalStep;
}
public IEnumerable<OUTPUT> Process(IEnumerable<INPUT> input)
{
foreach(INPUT item in input)
{
yield return _internalStep.Process(item);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment