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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s