Skip to content

Instantly share code, notes, and snippets.

@codereflection
Created October 7, 2010 20:09
Show Gist options
  • Select an option

  • Save codereflection/615802 to your computer and use it in GitHub Desktop.

Select an option

Save codereflection/615802 to your computer and use it in GitHub Desktop.
public static class ReadAllLinesHelper
{
public static IEnumerable<string> For(this string[] lines)
{
return lines;
}
public static IEnumerable<T> EachLineWeCareAbout<T>(this IEnumerable<string> lines, IParser parser)
{
return lines.Where(parser.CanParse).Select(parser.Parse) as IEnumerable<T>;
}
public static IEnumerable<T> Save<T>(this IEnumerable<T> items, IRepository<T> repo)
{
items.Each(repo.Save);
return items;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment