Пример #1
0
        public static LogMomentResultModel TransformObject(string jsonObject)
        {
            dynamic jObject = JObject.Parse(jsonObject);

            var logMoments         = Enumerable.Empty <LogMomentModel>();
            var total              = (int)jObject.totalResults;
            var containsLogMoments = (bool)jObject.containsLogMoments;

            if (total > 0)
            {
                logMoments = TransformArray(jObject.results);
            }
            var searchHighlightList = SearchHighlightTransforms.TransformArray(jObject.searchHighlights.ToString());

            return(new LogMomentResultModel(logMoments, total, containsLogMoments, searchHighlightList));
        }
Пример #2
0
        public static VideoCollectionModel TransformArray(string jsonArray)
        {
            dynamic jObject = JObject.Parse(jsonArray);

            if (jObject == null)
            {
                return(new VideoCollectionModel(Enumerable.Empty <VideoModel>(), 0, 0, Enumerable.Empty <SearchHighlightCollectionModel>()));
            }

            var videoArray = JArray.Parse(jObject.results.ToString());
            var videoList  = new List <VideoModel>();

            foreach (var json in videoArray)
            {
                videoList.Add(VideoTransforms.Transform(json));
            }

            var totalCount          = (int)jObject.totalCount.Value;
            var pageSize            = (int)jObject.pageSize.Value;
            var searchHighlightList = SearchHighlightTransforms.TransformArray(jObject.searchHighlights.ToString());

            return(new VideoCollectionModel(videoList, totalCount, pageSize, searchHighlightList));
        }