Пример #1
0
        public IEnumerable <T> SearchFTS <T>(int start = 0, int limit = 0, params string[] query) where T : E3SEntity
        {
            HttpClient client           = CreateClient();
            var        requestGenerator = new FTSRequestGenerator(BaseAddress);

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

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

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

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

            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);
        }