/// <summary> /// 刷新报纸,获取文章列表 /// </summary> public async Task <List <NewsItem> > GetNewsListAsync() { OnNewsRefreshing?.Invoke(); List <NewsItem> newNewsitems = new List <NewsItem>(); int originalNewsCount = NewsList.Count; foreach (var feedUrl in FeedUrls) { var syndicationClient = new SyndicationClient(); try { var feed = await new SyndicationClient().RetrieveFeedAsync(feedUrl); feed.Id = feedUrl.AbsoluteUri; FeedModel feedModel = new FeedModel(feed); if (!Feeds.Contains(feedModel)) { Feeds.Add(feedModel); } //将新闻添加到newsItems中 for (int retrievedNewsIndex = feed.Items.Count - 1; retrievedNewsIndex >= 0; --retrievedNewsIndex) { var newsLink = feed.Items[retrievedNewsIndex].ItemUri ?? feed.Items[retrievedNewsIndex].Links.Select(l => l.Uri).FirstOrDefault(); var newsItem = new NewsItem(feed.Items[retrievedNewsIndex], newsLink, PaperTitle, feed); //如果原新闻列表中不包含改新闻,则添加到新闻列表 if (!NewsList.Contains(newsItem)) { newNewsitems.Add(newsItem); NewsList.Add(newsItem); } } var orderedNewsList = NewsList.OrderBy(news => news.PublishedDate); NewsList = orderedNewsList.ToList(); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); OnUpdateFailed?.Invoke(feedUrl.AbsoluteUri); } } if (NewsList.Count > originalNewsCount) { OnNewsRefreshed?.Invoke(NewsList); } else { NoNewNews?.Invoke(); } if (NewsList.Count != originalNewsCount) { await SaveToFile(this); OnNewsUpdatedToFile?.Invoke(); } return(NewsList); }
public void LevelUP() { Debug.Log("Покупаем стулл"); if (levels.Length > level + 1) { if (ShopManager.Money >= levels[level + 1].price) { if (ChooseSystem.RData.TryShelfLevelUp()) { ShopManager.Money -= levels[level + 1].price; level++; ChangeModel(level); ChooseSystem.RData.ShelfLevelUp(); OnSelectedItem?.Invoke(this); } else { Debug.LogAssertion("ERROR : Не удалось проверить уровень стула"); OnUpdateFailed?.Invoke(this); } } } }