Example #1
0
        public AtomEntry(IFeedItem source)
        {
            // ** IFeedMetadata

            // ID
            Id = source.ID.ToString();

            // Title
            string title = source.Title;

            if (!string.IsNullOrWhiteSpace(title))
            {
                Title = title;
            }

            // Description
            string description = source.Description;

            if (!string.IsNullOrEmpty(description))
            {
                Summary = description;
            }

            // Author
            string author = source.Author;

            if (!string.IsNullOrEmpty(author))
            {
                Authors.Add(new AtomPerson
                {
                    Name = author
                });
            }

            // Published
            DateTime?published = source.Published;

            if (published.HasValue)
            {
                Updated = published.Value;
            }

            // Updated
            DateTime?updated = source.Updated;

            if (updated.HasValue)
            {
                Updated = updated.Value;
            }

            // Link
            Uri link = source.Link;

            if (link != null)
            {
                Links.Add(new AtomLink(link.ToString()));
            }

            // ImageLink
            Uri imageLink = source.ImageLink;

            if (imageLink != null)
            {
                Links.Add(new AtomLink
                {
                    Type     = "image",
                    Href     = imageLink.ToString(),
                    Relation = AtomLinkRelation.Enclosure
                });
            }

            // ** IFeedItem

            // Content
            string content = source.Content;

            if (!string.IsNullOrEmpty(content))
            {
                Content = new AtomContent(content);
            }

            // ThreadLink
            Uri      threadLink = source.ThreadLink;
            AtomLink replies    = null;

            if (threadLink != null)
            {
                replies = new AtomLink
                {
                    Href     = threadLink.ToString(),
                    Relation = AtomLinkRelation.Replies
                };
                Links.Add(replies);
            }

            // ThreadCount
            int?threadCount = source.ThreadCount;

            if (threadCount.HasValue && replies != null)
            {
                replies.ThreadCount = threadCount.Value;
            }

            // ThreadUpdated
            DateTime?threadUpdated = source.ThreadUpdated;

            if (threadUpdated.HasValue && replies != null)
            {
                replies.ThreadUpdated = threadUpdated.Value;
            }
        }
Example #2
0
	    public AtomEntry(IFeedItem source)
        {
            // ** IFeedMetadata

            // ID
            Id = source.ID.ToString();

            // Title
            string title = source.Title;
            if (!string.IsNullOrWhiteSpace(title))
            {
                Title = title;
            }

            // Description
            string description = source.Description;
            if (!string.IsNullOrEmpty(description))
            {
                Summary = description;
            }

            // Author
            string author = source.Author;
            if (!string.IsNullOrEmpty(author))
            {
                Authors.Add(new AtomPerson
                {
                    Name = author
                });
            }

            // Published
            DateTime? published = source.Published;
            if (published.HasValue)
            {
                Updated = published.Value;
            }

            // Updated
            DateTime? updated = source.Updated;
            if (updated.HasValue)
            {
                Updated = updated.Value;
            }

            // Link
            Uri link = source.Link;
            if (link != null)
            {
                Links.Add(new AtomLink(link.ToString()));
            }

            // ImageLink
            Uri imageLink = source.ImageLink;
            if (imageLink != null)
            {
                Links.Add(new AtomLink
                {
                    Type = "image",
                    Href = imageLink.ToString(),
                    Relation = AtomLinkRelation.Enclosure
                });
            }

            // ** IFeedItem

            // Content
	        string content = source.Content;
	        if (!string.IsNullOrEmpty(content))
	        {
	            Content = new AtomContent(content);
	        }

            // ThreadLink
	        Uri threadLink = source.ThreadLink;
	        AtomLink replies = null;
	        if (threadLink != null)
	        {
	            replies = new AtomLink
	            {
	                Href = threadLink.ToString(),
                    Relation = AtomLinkRelation.Replies
	            };
                Links.Add(replies);
	        }

            // ThreadCount
	        int? threadCount = source.ThreadCount;
	        if (threadCount.HasValue && replies != null)
	        {
	            replies.ThreadCount = threadCount.Value;
	        }

            // ThreadUpdated
	        DateTime? threadUpdated = source.ThreadUpdated;
	        if (threadUpdated.HasValue && replies != null)
	        {
	            replies.ThreadUpdated = threadUpdated.Value;
	        }
        }