public HttpResponseMessage TryExecute <TResult>(Expression expression, out TResult result) { result = default(TResult); var elementType = TypeSystem.GetElementType(typeof(TResult)); var uri = BuildRequestUri(expression, elementType); // http://localhost:20000/products?$skip=1&$top=1 // Append optional search options. if (this.query.Options != null) { var builder = new UriBuilder(uri); HttpNameValueCollection querystring = HttpNameValueCollection.Parse(builder.Query.TrimStart('?')); querystring.Add(this.query.Options); builder.Query = querystring.ToString(); uri = builder.Uri; } #if DEBUG Debug.WriteLine("Query uri: " + uri.AbsoluteUri); #endif var response = this.query.EntityClient.http.Get(uri); if (response.IsSuccessStatusCode) { result = this.query.EntityClient.EntityFormatter.FromContent <TResult>(response.Content); } return(response); }
public void WhenChainingAdd_ThenCanContinueAdding() { var collection = new HttpNameValueCollection() .Add("tag", ".net") .Add("tag", "wpf") .Add("foo", "bar"); var query = collection.ToString(); Assert.True(query.IndexOf("tag") != query.LastIndexOf("tag"), "Tag should appear twice"); Assert.True(query.Contains("foo=bar")); }
public void WhenCreatingWithAnonymousAdd_ThenCanAddMultivalue() { var collection = new HttpNameValueCollection { { "tag", ".net", "wpf" }, { "foo", "bar" }, }; var query = collection.ToString(); Assert.True(query.IndexOf("tag") != query.LastIndexOf("tag"), "Tag should appear twice"); Assert.True(query.Contains("foo=bar")); }