Пример #1
0
        public IEnumerable SearchFts(Type type, List <string> queryParts, int start = 0, int limit = 0)
        {
            var list = Activator.CreateInstance(typeof(List <>).MakeGenericType(type)) as IList;

            if (queryParts.Count == 0)
            {
                return(list);
            }

            HttpClient client           = CreateClient();
            var        requestGenerator = new FtsRequestGenerator(_baseAddress);

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

            var resultString = client.GetStringAsync(request).Result;
            var endType      = typeof(FTSResponse <>).MakeGenericType(type);
            var result       = JsonConvert.DeserializeObject(resultString, endType);

            foreach (object item in (IEnumerable)endType.GetProperty("items").GetValue(result))
            {
                list?.Add(item.GetType().GetProperty("data").GetValue(item));
            }

            return(list);
        }
Пример #2
0
        public IEnumerable <T> SearchFts <T>(List <string> queryParts, int start = 0, int limit = 0) where T : E3SEntity
        {
            HttpClient client           = CreateClient();
            var        requestGenerator = new FtsRequestGenerator(_baseAddress);

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

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

            return(JsonConvert.DeserializeObject <FTSResponse <T> >(resultString).items.Select(t => t.data));
        }