예제 #1
0
        public List<RssFeedItem> Obter(string url)
        {
            var feed = new RssFeedReader().ListarFeed(url);

            //Separei para manter o conceito de Single Responsability
            var listaFeedItem = new RssFeedItem().ConverterListaFeed(feed);

            return listaFeedItem;
        }
예제 #2
0
        public List<RssFeedItem> ConverterListaFeed(SyndicationFeed feed)
        {
            List<RssFeedItem> listaFeedItem = new List<RssFeedItem>();

            foreach (var item in feed.Items)
            {
                var feedItem = new RssFeedItem();

                feedItem.Titulo = item.Title.Text;
                feedItem.Url = item.Links.FirstOrDefault().Uri.ToString();
                feedItem.Descricao = item.Summary.Text;
                feedItem.DataPublicacao = item.PublishDate.DateTime;
                feedItem.Conteudo = item.ElementExtensions.ReadElementExtensions<string>("encoded", "http://purl.org/rss/1.0/modules/content/").FirstOrDefault();
                listaFeedItem.Add(feedItem);

            }
            return listaFeedItem;
        }