private string GetResultString(Type type, string query, int start, int limit) { var client = CreateClient(); var requestGenerator = new FTSRequestGenerator(_uri); var request = requestGenerator.GenerateRequestUrl(type, query, start, limit); var resultString = client.GetStringAsync(request).Result; return(resultString); }
public IEnumerable <T> SearchFTS <T>(string query, int start = 0, int limit = 0) where T : BaseE3SEntity { var requestGenerator = new FTSRequestGenerator(_baseAddress); Uri request = requestGenerator.GenerateRequestUrl <T>(query, start, limit); string resultString = _httpClient.GetStringAsync(request).Result; return(JsonConvert.DeserializeObject <FTSResponse <T> >(resultString).Items.Select(t => t.Data)); }
public IEnumerable SearchFTS(Type type, string query, int start = 0, int limit = 0) { var requestGenerator = new FTSRequestGenerator(_baseAddress); Uri request = requestGenerator.GenerateRequestUrl(type, query, start, limit); string resultString = _httpClient.GetStringAsync(request).Result; Type endType = typeof(FTSResponse <>).MakeGenericType(type); object result = JsonConvert.DeserializeObject(resultString, endType); var list = Activator.CreateInstance(typeof(List <>).MakeGenericType(type)) as IList; foreach (object item in (IEnumerable)endType.GetProperty("items").GetValue(result)) { list.Add(item.GetType().GetProperty("data").GetValue(item)); } return(list); }