public IEnumerable<T> SearchFTS<T>(string query, int start = 0, int limit = 0) where T : E3SEntity
		{
			HttpClient client = CreateClient();
			var requestGenerator = new FTSRequestGenerator(BaseAddress);

			Uri request = requestGenerator.GenerateRequestUrl<T>(query, start, limit);

			var resultString = client.GetStringAsync(request).Result;

			return JsonConvert.DeserializeObject<FTSResponse<T>>(resultString).items.Select(t => t.data);
		}
示例#2
0
        public IEnumerable SearchFTS(Type type, string query, int start = 0, int limit = 0)
        {
            HttpClient client           = CreateClient();
            var        requestGenerator = new FTSRequestGenerator(BaseAddress);

            Uri request = requestGenerator.GenerateRequestUrl(type, query, start, limit);

            var resultString = client.GetStringAsync(request).Result;
            var endType      = typeof(FTSResponse <>).MakeGenericType(type);
            var 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);
        }