Skip to content

Instantly share code, notes, and snippets.

@amogram
Created June 9, 2014 11:02
Show Gist options
  • Save amogram/e744fd7fd736e29e83cc to your computer and use it in GitHub Desktop.
Save amogram/e744fd7fd736e29e83cc to your computer and use it in GitHub Desktop.
public static TResult With<TInput, TResult>(this TInput o,
Func<TInput, TResult> evaluator)
where TResult : class
where TInput : class
{
if (o == null) return null;
return evaluator(o);
}
public static TResult Return<TInput, TResult>(this TInput o,
Func<TInput, TResult> evaluator,
TResult failureValue) where TInput : class
{
if (o == null) return failureValue;
return evaluator(o);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment