Exemple #1
0
        public AtomFeed(IFeed 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))
            {
                SubTitle = 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
                {
                    Href = link.ToString(),
                    Rel  = "self"
                });
            }

            // ImageLink
            Uri imageLink = source.ImageLink;

            if (imageLink != null)
            {
                Logo = imageLink.ToString();
            }

            // ** IFeed

            // Copyright
            string copyright = source.Copyright;

            if (!string.IsNullOrEmpty(copyright))
            {
                Rights = new AtomText(copyright);
            }

            // Items
            IList <IFeedItem> sourceItems = source.Items;

            if (sourceItems != null)
            {
                Entries.AddRange(sourceItems.Select(x => new AtomEntry(x)));
            }
        }
Exemple #2
0
        public AtomFeed(IFeed 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))
            {
                SubTitle = 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
                {
                    Href = link.ToString(),
                    Rel = "self"
                });
            }

            // ImageLink
            Uri imageLink = source.ImageLink;
            if (imageLink != null)
            {
                Logo = imageLink.ToString();
            }

            // ** IFeed

            // Copyright
            string copyright = source.Copyright;
            if (!string.IsNullOrEmpty(copyright))
            {
                Rights = new AtomText(copyright);
            }

            // Items
            IList<IFeedItem> sourceItems = source.Items;
            if (sourceItems != null)
            {
                Entries.AddRange(sourceItems.Select(x => new AtomEntry(x)));
            }
        }