Beispiel #1
0
        /// <summary>
        /// Converts the Model BlogEntry to a syndication item.
        /// </summary>
        /// <param name="entry">The model blog entry.</param>
        /// <returns>A <see cref="SyndicationItem"/> representation of the <see cref="BlogEntry"/> object.</returns>
        public static SyndicationItem ConvertToSyndicationItem(this BlogEntry entry, Uri baseUri)
        {
            SyndicationItem sItem = new SyndicationItem();

            sItem.Id              = entry.BlogEntryId.ToString();
            sItem.PublishDate     = entry.CreationDate;
            sItem.LastUpdatedTime = entry.LastUpdateDate;
            sItem.Title           = new TextSyndicationContent(entry.Title);
            // assume only one author - Me
            if (entry.Author != null)
            {
                sItem.Authors.Add(entry.Author.ConvertToSyndicationPerson());
            }
            sItem.BaseUri = baseUri;
            sItem.Content = new TextSyndicationContent(entry.Content);

            sItem.Links.Add(new SyndicationLink(new Uri(entry.CreateBlogUrl(baseUri.Authority))));

            foreach (var category in entry.Categories)
            {
                sItem.Categories.Add(category.ConvertToSyndicationCategory());
            }

            return(sItem);
        }