示例#1
0
        public static T LoadRssFromOpmlUrl <T>(string url) where T : RssDocumentBase
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The argument '{0}' is Null or Empty", "url"));
            }

            // resolve app-relative URLs
            url = RssXmlHelper.ResolveAppRelativeLinkToUrl(url);

            RssAggregator aggregator = new RssAggregator();

            aggregator.Load(new System.Uri(url));
            string rssXml = aggregator.RssXml;

            return(RssXmlHelper.DeserializeFromXmlUsingStringReader <T>(rssXml));
        }
示例#2
0
        protected static T Load <T>(System.Uri url) where T : RssDocumentBase
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            // resolve app-relative URLs
            string rssUrl = RssXmlHelper.ResolveAppRelativeLinkToUrl(url.ToString());

            // download the feed
            using (Stream cachedXml = DownloadManager.GetFeed(rssUrl))
            {
                using (XmlTextReader reader = new XmlTextReader(cachedXml))
                {
                    T rss = Load <T>(reader);

                    //// remember the url
                    rss.Url = rssUrl;

                    return(rss);
                }
            }
        }