Load() public method

public Load ( [ feed ) : void
feed [
return void
コード例 #1
0
ファイル: Feeds.cs プロジェクト: flcdrg/Gardiner.Podcasts
        public IList<SyndicationItem> Thing(string text)
        {
            SyndicationFeed feed = new SyndicationFeed();

            feed.Load(text);

            return feed.Items;
        }
コード例 #2
0
        public static SyndicationFeed Parse(string xml)
        {
            //DtdProcessing = DtdProcessing.Ignore is needed for some feeds (e.g. http://www.dotnetrocks.com/feed.aspx)
	        var feed = new SyndicationFeed();
			var xmlDoc = new XmlDocument();
			xmlDoc.LoadXml(xml);
			feed.Load(xmlDoc.GetXml());
			//feed.Load(reader.ReadContentAsString());
			return feed;
        }
コード例 #3
0
        private static async void RefreshModelRssFeed(ProgressBarHelper progressBarHelper)
        {
            App.MainViewModel.RssItems.Clear();
            string url = PreferenceHelper.GetPreference("RSS_FollowerPath");
            if (string.IsNullOrEmpty(url))
            {
                progressBarHelper.PopTask();
                return;
            }
            RestClient client = new RestClient();
            RestRequest request = new RestRequest();
            client.Authority = url;
            request.Method = Method.Get;
            RestResponse response = await client.BeginRequest(request);

            if(response.Error == RestError.ERROR_SUCCESS && response.Content != null)
            {                
                try
                {
                    SyndicationFeed feed = new SyndicationFeed();                    
                    feed.Load(response.Content);
                    foreach (SyndicationItem item in feed.Items)
                    {
                        ItemViewModel model = RSSFeedConverter.ConvertFeedToCommon(item);
                        if (model != null)
                        {
                            App.MainViewModel.RssItems.Add(model);
                        }
                    }   
                }
                catch (System.Exception ex)
                {
                    DialogHelper.ShowToastDialog("RSS获取中发生错误,可能是网络问题,也可能是对应站点地址变更");                   
                }
                finally
                {
                    progressBarHelper.PopTask(); 
                }
            }
            else
            {
                DialogHelper.ShowToastDialog("RSS获取中发生错误,可能是网络问题,也可能是对应站点地址变更");
                progressBarHelper.PopTask(); 
            }           
              
        }
コード例 #4
0
ファイル: MRssService.cs プロジェクト: 745322878/Code
        ///获取Rss目录列表
        public static void GetRssItems(string rssFeed, Action<IEnumerable<RssItem>> onGetRssItemsCompleted = null, Action<string> onError = null,
            Action onFinally = null)
        {
            var request = HttpWebRequest.Create(rssFeed);
            request.Method = "GET";
            request.BeginGetResponse((result) =>
            {
                try
                {
                    HttpWebRequest httpWebResquest = (HttpWebRequest)result.AsyncState;
                    WebResponse webResponse = httpWebResquest.EndGetResponse(result);
                    using (Stream stream = webResponse.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string content = reader.ReadToEnd();
                            //将网络获取的信息转化成RSS实体类
                            List<RssItem> rssItems = new List<RssItem>();
                            SyndicationFeed feeds = new SyndicationFeed();
                            feeds.Load(content);
                            foreach (SyndicationItem f in feeds.Items)
                            {
                                RssItem rssItem = new RssItem(f.Title.Text, f.Summary.Text, f.PublishedDate.ToString(), f.Links[0].Uri.AbsoluteUri);
                                rssItems.Add(rssItem);
                            }
                            if (onGetRssItemsCompleted != null)
                            {
                                onGetRssItemsCompleted(rssItems);
                            }
                        }

                    }
                }
                catch (WebException webEx)
                {
                    string exceptionInfo = "";
                    switch (webEx.Status)
                    {
                        case WebExceptionStatus.ConnectFailure:
                            exceptionInfo = "ConnectFaliure:远程服务器连接失败";
                            break;
                        case WebExceptionStatus.MessageLengthLimitExceeded:
                            exceptionInfo = "MessageLengthLimitExceeded:网络请求的信息长度受到限制";
                            break;
                        case WebExceptionStatus.Pending:
                            exceptionInfo = "Pending:内部异步请求挂起";
                            break;
                        case WebExceptionStatus.RequestCanceled:
                            exceptionInfo = "RequestCaneled:该请求将被取消";
                            break;
                        case WebExceptionStatus.SendFailure:
                            exceptionInfo = "SendFailure:发送失败,未能将完整请求发送到";
                            break;
                        case WebExceptionStatus.UnknownError:
                            exceptionInfo = "UnknownError:未知错误";
                            break;
                        case WebExceptionStatus.Success:
                            exceptionInfo = "Success :请求成功";
                            break;
                        default:
                            exceptionInfo = "未知网络异常";
                            break;
                    }
                    if (onError != null)
                        onError(exceptionInfo);
                }
                catch (Exception e)
                {
                    if (onError != null)
                        onError("异常" + e.ToString());
                }
                finally
                {
                    if (onFinally != null)
                        onFinally();
                }
            }, request);
        }
コード例 #5
0
 public NewsFeed Parse(string rss)
 {
     var syndicationFeed = new SyndicationFeed();
     syndicationFeed.Load(rss);
     return new NewsFeed(TransformRssFeedToNewsItems(syndicationFeed));
 }
コード例 #6
0
 private async void RssSetPathCallback(String path)
 {
     RestClient client = new RestClient();
     RestRequest request = new RestRequest();
     client.Authority = path;
     request.Method = Method.Get;
     RestResponse response = await client.BeginRequest(request);
     if (response.Error == RestError.ERROR_SUCCESS && response.Content != null)
     {
         try
         {
             SyndicationFeed feed = new SyndicationFeed();
             feed.Load(response.Content);
             FollowerSitePath = path;
             FollowerSiteName = feed.Title.Text;
             PreferenceHelper.SetPreference("RSS_FollowerPath", FollowerSitePath);
             PreferenceHelper.SetPreference("RSS_FollowerSite", FollowerSiteName);
             App.MainViewModel.IsChanged = true;
         }
         catch
         {
             FollowerSiteName = "未关注";
             FollowerSitePath = "未设置";
             PreferenceHelper.RemovePreference("RSS_FollowerPath");
             PreferenceHelper.RemovePreference("RSS_FollowerSite");
             DialogHelper.ShowMessageDialog("刚刚输入的为无效Rss地址", "悲剧鸟");
         }
     }
     else
     {
         DialogHelper.ShowMessageDialog("刚刚输入的rss地址无效,请检查拼写正确,并确保网络畅通", "悲剧鸟");
     }
 }
コード例 #7
0
        /// <summary>
        /// Extracts queues from the given HTTP response.
        /// </summary>
        /// <param name="response">HTTP response.</param>
        /// <returns>Collection of queues.</returns>
        private IEnumerable<QueueInfo> GetQueues(HttpResponseMessage response)
        {
            Debug.Assert(response.IsSuccessStatusCode);
            SyndicationFeed feed = new SyndicationFeed();
            feed.Load(response.Content.ReadAsStringAsync().Result);

            return SerializationHelper.DeserializeCollection<QueueInfo>(feed, (item, queue) => queue.Initialize(item));
        }