Thursday, April 8, 2010

Modification to RSS.NET to allow Sorting of Items

In RssItemCollection.cs
------------------------
///
/// Sorting for RSSItem
///
public void Sort()
{
InnerList.Sort(new RssItemComparer());
}

class RssItemComparer : IComparer
{
public int Compare(object x, object y)
{
return ((RssItem)y).CompareTo((RssItem)x);
}
}

in RssItem.cs
--------------
public int CompareTo(object obj)
{
return this.pubDate.CompareTo(((RssItem)obj).pubDate);
}

No comments:

Post a Comment