private static Result BuildResult(string collectionName, string key, BaseResult baseResult) { return new Result { Path = new Path { Collection = collectionName, Key = key, Ref = baseResult.ETag }, Score = 1, Value = baseResult.Payload }; }
private static BaseResult BuildResult(Task<HttpResponseMessage> responseMessageTask) { var response = responseMessageTask.Result; response.EnsureSuccessStatusCode(); var payload = response.Content.ReadAsStringAsync().Result; var location = response.Headers.Location?.ToString() ?? string.Empty; var eTag = response.Headers.ETag != null ? response.Headers.ETag.Tag : string.Empty; var toReturn = new BaseResult { Location = location, ETag = eTag, Payload = payload }; return toReturn; }
private static string ExtractKeyFromLocation(BaseResult baseResult) { // Always in the format /<api version>/<collection>/<key>/refs/<ref> var locationParts = baseResult.Location.Split('/'); return locationParts[3]; }