How to Generate an AtomFeed using Argotic Framework. Part 4

Argotic Framework provides several classes which are great for the manipulation of a feed resource. AtomFeed class could helps us retrive all the required bits about particular Atom based feed resource and latest content it holds. On the other hand we can use the same class to generate a feed for our on line resources as well. Below is sample program which demonstrates an AtomFeed Object in action.

// create a new AtomFeed Object
                AtomFeed feed = new AtomFeed();

                // Set the title for the feed
                feed.Title = new AtomTextConstruct("codingphobia.com articles");

                // set the language you Feed is published in
                feed.Language = new System.Globalization.CultureInfo("en-gb");

                // set the description for the Feed / Feed resource
                feed.Subtitle = new AtomTextConstruct("Latest Content from codingphobia.com");

                // Set the categories under the Feed / content is published
                feed.Categories.Add(new AtomCategory("AtomFeed"));
                feed.Categories.Add(new AtomCategory("cSharp"));
                feed.Categories.Add(new AtomCategory("SyndicationFeed"));

                // Set the information about the feed Generator Engine
                feed.Generator = new AtomGenerator("WordPress3.0");

                // Add the List of Post / Articles / content links 
                // and information to the Feed Object

                // Adding  Article 1
                AtomEntry atomEntry = new AtomEntry();
                atomEntry.BaseUri = new Uri("http://codingphobia.com/category/c/page/2/");
                atomEntry.Categories.Add(new AtomCategory("Fameworks"));
                atomEntry.Title = 
                    new AtomTextConstruct("Really simple syndication -RSS with .Net. Intro");
                atomEntry.Content = new AtomContent("Some content", UTF32Encoding.Unicode.BodyName);
                atomEntry.PublishedOn = DateTime.Now;
                feed.AddEntry(atomEntry);

                // Adding  Article 2
                atomEntry.BaseUri = new Uri("http://codingphobia.com/category/c/page/1/");
                atomEntry.Categories.Add(new AtomCategory("FeedTypes"));
                atomEntry.Title = new AtomTextConstruct("RSS with .Net. Part1");
                atomEntry.Content = new AtomContent("Some more content", UTF32Encoding.Unicode.BodyName);
                atomEntry.PublishedOn = DateTime.Now;
                feed.AddEntry(atomEntry);

                // Set the url for the Icon for your Feed
                // Displayed on the side of the feed page
                feed.Icon = new AtomIcon(new Uri("http://codingphobia.com/officialImage"));

                // Set the url for the logo for your Feed
                // Displayed on the side of the feed page
                feed.Logo = new AtomLogo(new Uri("http://codingphobia.com/officialLogo"));

                // Set the right for feed consumption 
                feed.Rights = new AtomTextConstruct("CC");     
Advertisements

How to Generate an Rss Feed using System.ServiceModel.Syndication Framework. Part 3

Syndication-Feed provides all the properties we will need to generate a feed for our web site. This article assumes that you have a Data Access layer, which could provide the objects / content and other information needed to publish a feed. I will be using sample variables and objects, which you can replace with originals content / objects

           // Create a raw SyndicationFeed object
            SyndicationFeed feed = new SyndicationFeed();

            // Set the title for the Feed
            feed.Title = new TextSyndicationContent("codingphobia.com articles");

            // set the language you Feed is published in
            feed.Language = "en-gb";

            // set the description for the Feed / Feed resource
            feed.Description = new TextSyndicationContent("Latest Content from codingphobia.com");

            // set the rights information that apply over 
            // the consumption / distribution of the  
            // Feed / content
            feed.Copyright = new TextSyndicationContent("CC");

            // Set the categories under the Feed / content is published
            feed.Categories.Add(new SyndicationCategory("RssFeed"));
            feed.Categories.Add(new SyndicationCategory("cSharp"));
            feed.Categories.Add(new SyndicationCategory("SyndicationFeed"));

            // Set the information about the feed Generator Engine
            feed.Generator = "WordPress3.0";

            // Add the List of Post / Articles / content links 
            // and information to the Feed Object
            List<SyndicationItem> feedItems = new List<SyndicationItem>();

           
            SyndicationItem feedItem1 =
                new SyndicationItem(
                    "Really simple syndication -RSS with .Net. (Intro)",
                    "Rss Feed Fameworks",
                    new Uri("http://codingphobia.com/category/c/page/2/"));
            feedItems.Add(feedItem1);

            SyndicationItem feedItem2 =
                new SyndicationItem(
                    "How to consume an Rss feed using System."+
                    "ServiceModel.Syndication Framework. (Part 1)",
                    "Consume Rss Feed",
                    new Uri("http://codingphobia.com/2009/07/06/how-to-consume-an"+
                    "-rss-feed-using-system-servicemodel-syndication-framework-part-2/"));
            feedItems.Add(feedItem2);

            SyndicationItem feedItem3 =
                new SyndicationItem(
                    "How to consume an Atom feed using Argotic Framework. (Part 2)",
                    "Consume Atom Feed",
                    new Uri("http://codingphobia.com/2009/07/09/how-to-consume-an-atom"+
                    "-feed-using-argotic-framework-part-2/"));
            feedItems.Add(feedItem3);

            // Set the url forthe image / logo for your Feed
            // Displayed on the side of the feed page
            feed.ImageUrl = new Uri("http://codingphobia.com/imageUrl");