static Tuple<int, Uri, int> ExtractLatest(IDictionary<string, CatalogItemSummary> currentPageEntries)
{
int maxPageNumber = -1;
Uri latestUri = null;
int latestCount = 0;
foreach (KeyValuePair<string, CatalogItemSummary> entry in currentPageEntries)
{
int first = entry.Key.IndexOf("page") + 4;
int last = first;
while (last < entry.Key.Length && char.IsNumber(entry.Key, last))
{
last++;
}
string s = entry.Key.Substring(first, last - first);
int pageNumber = int.Parse(s);
if (pageNumber > maxPageNumber)
{
maxPageNumber = pageNumber;
latestUri = new Uri(entry.Key);
latestCount = entry.Value.Count.Value;
}
}
return new Tuple<int, Uri, int>(maxPageNumber, latestUri, latestCount);
}
}