Created
November 8, 2019 00:20
-
-
Save TheFo2sh/a646968570e85282edb6ca9ef79c039c 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
static class LinQToTaskExtensions | |
{ | |
public static async Task<TResult> Select<TSource, TResult>( | |
this Task<TSource> source, Func<TSource, TResult> selector) | |
{ | |
var sourceResult = await source; | |
if (sourceResult == null) | |
return default(TResult); | |
return selector.Invoke(sourceResult); | |
} | |
public static async Task<TResult> SelectMany<TSource, TResult>(this Task<TSource> source, | |
Func<TSource, Task<TResult>> selector) | |
{ | |
var sourceResult = await source; | |
if (sourceResult == null) | |
return default(TResult); | |
return await selector.Invoke(sourceResult); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment