protected override async Task buildViewModelPosts(IEnumerable <IPost> posts) { clear(UnfilteredItems); clear(FilteredItems); var rawPosts = posts as IList <IPost> ?? posts.ToList(); var schedule = new Schedule(); var vms = new List <VkPostViewModel>(); var freshViewModels = await _postBuilder.BuildAsync(rawPosts); vms.AddRange(freshViewModels.Cast <VkPostViewModel>()); vms.Where(post => { var vmPost = post; if (vmPost == null) { return(false); } return(IsDateMatchTheSchedule(vmPost.Post.Date, schedule)); }).ForEach(post => { var vmPost = post; if (vmPost == null) { return; } vmPost.Mark = PostMark.Good; }); vms.Sort((a, b) => b.Post.Date.CompareTo(a.Post.Date)); UnfilteredItems.Clear(); UnfilteredItems.AddRange(vms); filterOut(vms); }
protected override async Task buildViewModelPosts(IEnumerable <IPost> posts) { var sw = Stopwatch.StartNew(); clear(UnfilteredItems); clear(FilteredItems); var rawPosts = posts as IList <IPost> ?? posts.ToList(); var schedule = new Schedule(); var vms = new List <VkPostViewModel>(); var freshViewModels = await _postBuilder.BuildAsync(rawPosts); vms.AddRange(freshViewModels.Cast <VkPostViewModel>()); vms.Where(post => { var vmPost = post; if (vmPost == null) { return(false); } return(IsDateMatchTheSchedule(vmPost.Post.Date, schedule)); }).ForEach(post => { var vmPost = post; if (vmPost == null) { return; } vmPost.Mark = PostMark.Good; }); #pragma warning disable 4014 _postBuilder.GetOwnerNamesOfPosts(vms.Where(post => post.PostType == PostType.Repost).ToList()); #pragma warning restore 4014 var missingFiller = new MissingFiller(); var missingDates = await missingFiller.GetMissingDates(rawPosts, schedule); var missingPosts = missingFiller.BuildMissingViewModels(missingDates).ToList(); missingPosts.ForEach(p => p.UploadRequested += onMissingPostRequestedUpload); vms.AddRange(missingPosts); vms.Sort((a, b) => a.Post.Date.CompareTo(b.Post.Date)); UnfilteredItems.Clear(); UnfilteredItems.AddRange(vms); filterOut(vms); sw.Stop(); Debug.WriteLine($"Потребовалось времени для билда: {sw.ElapsedMilliseconds}"); }