示例#1
0
        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();
        }
示例#2
0
 public void RemoveFeedData(FeedCacheItem Data)
 {
     FeedCacheList.Remove(Data);
     SaveFeedData();
 }
示例#3
0
        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);
        }