/// <summary> /// Builds the uri for purpose of probing any remaining entries satisfying the request of service context /// use the last entry's token in the feed as the marker of skiptoken; /// and reduce the $top count if top was in context request URI. /// </summary> /// <param name="context">The service context object</param> /// <returns>Uri object if a meaningful prober can be constructed; null otherwise </returns> private static Uri ConstructProbeUri(ServiceContext context) { Uri result = null; JObject response = JsonParserHelper.GetResponseObject(context); if (response != null) { JArray entries = JsonParserHelper.GetEntries(response); if (entries != null) { JObject lastEntry = JsonParserHelper.GetLastEntry(entries); if (lastEntry != null) { string lastToken = JsonParserHelper.GetTokenOfEntry(lastEntry); string lastTokenOfValues = ResourcePathHelper.GetValuesOfKey(lastToken); var uri = context.Destination; ResourcePathHelper pathHelper = new ResourcePathHelper(uri); // replace top value with the reduced value, if $top was in context request string topValue = pathHelper.GetQueryValue("$top"); if (!string.IsNullOrEmpty(topValue)) { pathHelper.RemoveQueryOption("$top"); int entriesGot = entries.Count; int entriesToGet; if (Int32.TryParse(topValue, out entriesToGet) && entriesToGet > entriesGot) { int entriesLeft = entriesToGet - entriesGot; pathHelper.AddQueryOption("$top", entriesLeft.ToString(CultureInfo.InvariantCulture)); } } // set up new skiptoken query pathHelper.RemoveQueryOption("$skiptoken"); pathHelper.AddQueryOption("$skiptoken", lastTokenOfValues); result = new Uri(pathHelper.Product); } } } return(result); }