public void AddFeedData(FeedCacheItem Data) { //filter var filtered_list = from item in FeedCacheList where item.url == Data.url orderby item.expireDate descending select item; //remove other same url foreach (var item in filtered_list) { if (item.expireDate != filtered_list.First().expireDate) { RemoveFeedData(item); } } //add FeedCacheList.Add(Data); SaveFeedData(); }
public void RemoveFeedData(FeedCacheItem Data) { FeedCacheList.Remove(Data); SaveFeedData(); }
void WebClient_RequestNewFeedXml_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { FeedCacheRequestEventArgs eventArg = new FeedCacheRequestEventArgs(); if (e.Error != null) { eventArg.Error = e.Error; } else { XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None); //save FeedCacheItem item = new FeedCacheItem() { expireDate = DateTime.Now.Add(TimeSpan.FromSeconds(1)), url = EncryptUrl((sender as WebClient).Headers["url"]) }; FeedCache.Instance.AddFeedData(item); WriteXmlFile(item.url, xdoc); //event_arg eventArg.Detail = item; eventArg.XmlData = xdoc; } FeedCacheRequestCompleted(eventArg); }