Created
June 8, 2011 21:25
-
-
Save developernotes/1015445 to your computer and use it in GitHub Desktop.
Enumeration extensions
This file contains 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 void WhenNotNullPerform<TType, TResult>(this IEnumerable<TType> items, Func<TType, TResult> conditionToCheck, Action<TResult> actionToApply) where TResult : class | |
{ | |
items.Each(x => | |
{ | |
var result = conditionToCheck.Invoke(x); | |
if (result != null) | |
{ | |
actionToApply.Invoke(result); | |
} | |
}); | |
} | |
public static void Each<TType>(this IEnumerable<TType> items, Action<TType> action) | |
{ | |
foreach (var item in items) { | |
action(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment