Created
November 16, 2010 17:16
-
-
Save anaisbetts/702099 to your computer and use it in GitHub Desktop.
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
IObservable<IDictionary<string, bool>> ValidateManyUrisAsync(string[] Uris) | |
{ | |
// Aggregate will take a "future list" and return a future with only one item | |
// (Just like LINQ's Aggregate takes a list and returns a single value) | |
// For every result that ValidateUrlAsync provides, we will execute the | |
// Aggregate block. When SelectMany completes, Aggregate can finally | |
// return its one result | |
return Uris.ToObservable() | |
.SelectMany(x => ValidateUriAsync(x)) | |
.Aggregate(new ConcurrentDictionary<string, bool>(), (acc, pair) => { | |
acc.TryAdd(pair.Key, pair.Value); | |
return acc; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment