private void AddChildren(ElementHost element, JArray elements) { element.Children.Clear(); var children = elements.Where(x => x["parentId"]?.ToString() == element.Id) .Select(x => WebElement.Create(x, this, element)); element.Children.AddRange(children); foreach (var child in element.Children) { AddChildren(child, elements); } }
private static void SetCommentCounts(JArray whatsThis, List<IGrouping<string, LogEntry>> tmp) { if (whatsThis != null) { foreach (var log in tmp) { var logComCnt = whatsThis.Where(x => x.Value<string>("Key") == log.Key); var firstOrDefault = logComCnt.FirstOrDefault(); if (firstOrDefault != null) log.First().CommentCount = firstOrDefault.Value<int>("Value"); } } }
private List<Category> GetCategoriesFromJArray(Category parentCategory, JArray array, bool getGenres) { List<Category> categories = new List<Category>(); foreach (JToken element in array.Where(e => (!getGenres && e["isGenre"].Value<string>() != "genre" && !e["url"].Value<string>().StartsWith("/video/")) || (getGenres && e["isGenre"].Value<string>() == "genre"))) { RssLink category = new RssLink() { Name = element["title"].Value<string>(), Thumb = element["thumbnail"].Value<string>(), Url = element["url"].Value<string>().Replace("genre/", "").Replace("/", ""), ParentCategory = parentCategory, SubCategories = new List<Category>(), HasSubCategories = true }; category.Thumb = (category.Thumb.StartsWith("/") ? string.Concat("http://www.svtplay.se", category.Thumb) : category.Thumb); category.Other = (getGenres ? (Func<List<Category>>)(() => GetTagCategories(category)) : (Func<List<Category>>)(() => GetProgramCategoriesAndVideos(category))); categories.Add(category); } categories = categories.OrderBy(c => c.Name).ToList<Category>(); return categories; }