Exemplo n.º 1
0
        private void SetNewFeeds(INewsCollector newsCollector, bool fireChanged)
        {
            var allFeeds = newsCollector.GetAllFeeds();

            _feeds.Clear();
            allFeeds.ForEach(f => _feeds.Add(f));
            if (fireChanged)
            {
                _feeds.FireChange();
            }
        }
Exemplo n.º 2
0
        public void Refresh()
        {
            INewsCollector newsCollector = ServiceRegistration.Get <INewsCollector>(false);

            if (newsCollector != null)
            {
                NewsItem newNewsItem = newsCollector.GetRandomNewsItem();
                if (newNewsItem != null)
                {
                    newNewsItem.CopyTo(CurrentNewsItem);

                    var feeds = newsCollector.GetAllFeeds().OrderByDescending(f => f.LastUpdated);
                    //Only update if changed
                    if (!feeds.Select(f => f.LastUpdated).SequenceEqual(_currentFeedItems.Select(f => (f as NewsFeed)?.LastUpdated ?? DateTime.Now)))
                    {
                        _currentFeedItems.Clear();
                        foreach (var feed in feeds)
                        {
                            feed.Command = new AsyncMethodDelegateCommand(() => ShowNews(feed));
                            _currentFeedItems.Add(feed);
                        }
                        _currentFeedItems.FireChange();
                    }

                    var items = newsCollector.GetAllNewsItems().OrderByDescending(i => i.PublishDate);
                    //Only update if changed
                    if (!items.Select(i => i.PublishDate).SequenceEqual(_currentNewsItems.Select(i => (i as NewsItem)?.PublishDate ?? DateTime.Now)))
                    {
                        _currentNewsItems.Clear();
                        _currentTopNewsItems.Clear();
                        foreach (var newsItem in items)
                        {
                            newsItem.Command = new AsyncMethodDelegateCommand(() => ShowNews(newsItem));
                            _currentNewsItems.Add(newsItem);
                            if (_currentTopNewsItems.Count < NEWSITEM_TOP_COUNT)
                            {
                                _currentTopNewsItems.Add(newsItem);
                            }
                        }
                        _currentNewsItems.FireChange();
                        _currentTopNewsItems.FireChange();
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void SetNewFeeds(INewsCollector newsCollector, bool fireChanged)
 {
   var allFeeds = newsCollector.GetAllFeeds();
   _feeds.Clear();
   allFeeds.ForEach(f => _feeds.Add(f));
   if (fireChanged)
     _feeds.FireChange();
 }