Ejemplo n.º 1
0
        /// <summary>
        /// Loads the generic syndication item using the supplied <see cref="RssItem"/>.
        /// </summary>
        /// <param name="item">The <see cref="RssItem"/> to build an abstraction against.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="item"/> is a null reference (Nothing in Visual Basic).</exception>
        private void LoadFrom(RssItem item)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(item, "item");

            //------------------------------------------------------------
            //	Initialize generic item
            //------------------------------------------------------------
            if (!String.IsNullOrEmpty(item.Title))
            {
                itemTitle       = item.Title.Trim();
            }

            if (item.PublicationDate != DateTime.MinValue)
            {
                itemPublishedOn = item.PublicationDate;
            }

            if (!String.IsNullOrEmpty(item.Description))
            {
                itemSummary     = item.Description.Trim();
            }

            foreach (RssCategory category in item.Categories)
            {
                GenericSyndicationCategory genericCategory  = new GenericSyndicationCategory(category);
                itemCategories.Add(genericCategory);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the generic syndication feed using the supplied <see cref="AtomFeed"/>.
        /// </summary>
        /// <param name="feed">The <see cref="AtomFeed"/> to build an abstraction against.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="feed"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Parse(AtomFeed feed)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(feed, "feed");

            //------------------------------------------------------------
            //	Initialize generic feed
            //------------------------------------------------------------
            feedResource            = feed;
            feedFormat              = SyndicationContentFormat.Atom;

            if (feed.Title != null && !String.IsNullOrEmpty(feed.Title.Content))
            {
                feedTitle           = feed.Title.Content;
            }

            if (feed.Subtitle != null && !String.IsNullOrEmpty(feed.Title.Content))
            {
                feedDescription     = feed.Subtitle.Content;
            }

            if (feed.UpdatedOn != DateTime.MinValue)
            {
                feedLastUpdatedOn   = feed.UpdatedOn;
            }

            if(feed.Language != null)
            {
                feedLanguage        = feed.Language;
            }

            foreach(AtomCategory category in feed.Categories)
            {
                GenericSyndicationCategory genericCategory  = new GenericSyndicationCategory(category);
                feedCategories.Add(genericCategory);
            }

            foreach(AtomEntry entry in feed.Entries)
            {
                GenericSyndicationItem genericItem  = new GenericSyndicationItem(entry);
                ((Collection<GenericSyndicationItem>)feedItems).Add(genericItem);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the generic syndication item using the supplied <see cref="AtomEntry"/>.
        /// </summary>
        /// <param name="entry">The <see cref="AtomEntry"/> to build an abstraction against.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entry"/> is a null reference (Nothing in Visual Basic).</exception>
        private void LoadFrom(AtomEntry entry)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entry, "entry");

            //------------------------------------------------------------
            //	Initialize generic item
            //------------------------------------------------------------
            if (entry.Title != null && !String.IsNullOrEmpty(entry.Title.Content))
            {
                itemTitle       = entry.Title.Content.Trim();
            }

            if (entry.PublishedOn != DateTime.MinValue)
            {
                itemPublishedOn = entry.PublishedOn;
            }
            else if (entry.UpdatedOn != DateTime.MinValue)
            {
                itemPublishedOn = entry.UpdatedOn;
            }

            if (entry.Summary != null && !String.IsNullOrEmpty(entry.Summary.Content))
            {
                itemSummary     = entry.Summary.Content.Trim();
            }
            else if (entry.Content != null && !String.IsNullOrEmpty(entry.Content.Content))
            {
                itemSummary     = entry.Content.Content.Trim();
            }

            foreach (AtomCategory category in entry.Categories)
            {
                GenericSyndicationCategory genericCategory  = new GenericSyndicationCategory(category);
                itemCategories.Add(genericCategory);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the generic syndication feed using the supplied <see cref="RssFeed"/>.
        /// </summary>
        /// <param name="feed">The <see cref="RssFeed"/> to build an abstraction against.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="feed"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Parse(RssFeed feed)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(feed, "feed");

            //------------------------------------------------------------
            //	Initialize generic feed
            //------------------------------------------------------------
            feedResource            = feed;
            feedFormat              = SyndicationContentFormat.Rss;

            if (!String.IsNullOrEmpty(feed.Channel.Title))
            {
                feedTitle           = feed.Channel.Title;
            }

            if (!String.IsNullOrEmpty(feed.Channel.Description))
            {
                feedDescription     = feed.Channel.Description;
            }

            if (feed.Channel.LastBuildDate != DateTime.MinValue)
            {
                feedLastUpdatedOn   = feed.Channel.LastBuildDate;
            }

            if (feed.Channel.Language != null)
            {
                feedLanguage        = feed.Channel.Language;
            }

            foreach (RssCategory category in feed.Channel.Categories)
            {
                GenericSyndicationCategory genericCategory  = new GenericSyndicationCategory(category);
                feedCategories.Add(genericCategory);
            }

            foreach (RssItem item in feed.Channel.Items)
            {
                GenericSyndicationItem genericItem  = new GenericSyndicationItem(item);
                ((Collection<GenericSyndicationItem>)feedItems).Add(genericItem);
            }
        }