Quick and Dirty Feed Parser 0.3 Now Available

My Christmas gift to the developer community: Quick and Dirty Feed Parser 0.3 is now available on CodePlex!

The big feature added in this release is the ability to perform IFeedFactory.CreateFeed operations asynchronously both for disc IO and network IO. I added this to QD Feed Parser primarily to support the use of asynchronous controllers in ASP.NET MVC3, and to support Silverlight and Windows Phone 7 eventually.

All classes which implement the IFeedFactory interface now have some new members:

IAsyncResult BeginCreateFeed(Uri feeduri, AsyncCallback callback);

IFeed EndCreateFeed(IAsyncResult asyncResult);

IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback);

FeedTuple EndDownloadXml(IAsyncResult asyncResult);

If you’re at all familiar with the Begin[Procedure] End[Procedure] asynchronous programming pattern in .NET, then the purpose of these functions should be self-evident. Internally, BeginCreateFeed and EndCreateFeed are dependent upon the output of BeginDownloadXml and EndDownloadXml, but should a developer want to be able to work strictly with just the XML content itself then that’s why the [Begin/End]DownloadXml methods are publicly exposed.

Here’s a quick example which shows how you can use these functions to quickly and asynchronously parse RSS and Atom feeds:

Uri feeduri;
IFeedFactory factory;
if (UseFileSys)
{
    feeduri = new Uri(Path.GetFullPath(strFeedUri));
    factory = new FileSystemFeedFactory();
}
else
{
    feeduri = new Uri(strFeedUri);
    factory = new HttpFeedFactory();
}

factory.BeginCreateFeed(feeduri, async =>
{
    var feed = factory.EndCreateFeed(async);
    foreach (var feedItem in feed.Items)
    {
        Console.WriteLine("{0} {1}",
			feedItem.DatePublished, feedItem.Title);
        Console.WriteLine(feedItem.Link);
    }
});

If you’d like to play with this example of using Quick and Dirty Feed Parser asynchronously you can download the source from Github or the full release from CodePlex.

Originally I developed Quick and Dirty Feed Parser to support legacy NET 2.0 projects that wanted functionality that you could find using the System.ServiceModel.Syndication namespace. I’m developing it going forward because I think it’s easier to use than the ServiceModel classes and I’m using it on my own projects going forward.

If you’re interested in contributing to the project, we’d love to have you. Check out our issues list or come up with your own feature ideas that aren’t in it yet!

Discussion, links, and tweets

I'm the CTO and co-founder of Petabridge, where I'm making distributed programming for .NET developers easy by working on Akka.NET and Helios.

P.S. Get the latest from Aaronontheweb

Have my most recent essays and articles delivered directly to your mailbox.