Created
October 7, 2010 20:09
-
-
Save codereflection/615802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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