Ejemplo n.º 1
0
        public FeedResult(string nickname, int feedId, string xml) : base()
        {
            try
            {
                var feed = new Syndication.FeedDetails(xml);



                this.Items.Add(new DirectoryItem(feed.Title));
                this.Items.Add(new DirectoryItem("---------------"));
                this.Items.Add(new DirectoryItem("Last Updated: " + feed.LastUpdated.ToString()));
                this.Items.Add(new DirectoryItem("Delete Feed", Settings.HomePath + string.Format("/user/{0}/delete/{1}/", nickname, feedId)));
                this.Items.Add(new DirectoryItem(""));
                this.Items.Add(new DirectoryItem("Return to Feed List", Settings.HomePath + string.Format("/feeds/{0}/", nickname)));
                this.Items.Add(new DirectoryItem(""));

                foreach (var item in feed.Feed.Items)
                {
                    this.Items.Add(new DirectoryItem(item.Title.Text, Settings.HomePath + string.Format("/feeds/{0}/{1}/{2}", nickname, feedId, item.Id)));
                    //this.Items.Add(new DirectoryItem("Author(s): " + string.Join(", ", item.Authors.Select(a => a.Name))));
                    this.Items.Add(new DirectoryItem("Published: " + item.PublishDate.UtcDateTime.ToString()));
                    this.Items.AddRange(item.Summary.Text.HtmlToText().WrapToDirectoryItems());

                    this.Items.Add(new DirectoryItem("---"));
                }
            }
            catch (Exception)
            {
                this.Items.Add(new DirectoryItem("Error Processing Feed."));
            }

            this.Items.Add(new DirectoryItem("Return to Feed List", Settings.HomePath + string.Format("/feeds/{0}/", nickname)));
        }
Ejemplo n.º 2
0
        public FeedItemResult(string nickname, int feedId, string xml, string itemId) : base()
        {
            var feed = new Syndication.FeedDetails(xml);
            // Find the item
            var    item = feed.Feed.Items.FirstOrDefault(i => i.Id == itemId);
            string text;
            var    content = item.Content as TextSyndicationContent;

            if (content != null)
            {
                text = content.Text;
            }
            else
            {
                text = item.Summary.Text;
            }

            this.Items.Add(new DirectoryItem(item.Title.Text));
            this.Items.Add(new DirectoryItem("------------"));
            this.Items.Add(new DirectoryItem(item.PublishDate.UtcDateTime.ToString()));
            this.Items.AddRange(text.HtmlToText().WrapToDirectoryItems());

            if (item.Links.Any())
            {
                this.Items.Add(new ExternalUrlItem("Read More...", item.Links.First().Uri.ToString()));
            }

            this.Items.Add(new DirectoryItem("---"));

            this.Items.Add(new DirectoryItem("Return to '" + feed.Title + "'...", string.Format("/feeds/{0}/{1}/", nickname, feedId)));
            this.Items.Add(new DirectoryItem("Return to Feed List...", string.Format("/feeds/{0}/", nickname)));
        }