Click here to Skip to main content
15,888,320 members
Articles / Programming Languages / XML

Silverlight 1.1 Fun and Games

Rate me:
Please Sign up or sign in to vote.
4.91/5 (126 votes)
1 Nov 200727 min read 384.3K   816   238  
Silverlight 1.1 Fun and Games
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Collections.Generic;

public class RSSFeed
{
    #region Instance fields
    private const string _FLICKR_API_KEY = "c705bfbf75e8d40f584c8a946cf0834c";
    private const string _MOST_RECENT = "http://www.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=" + _FLICKR_API_KEY;
    private const string _INTERESTING = "http://www.flickr.com/services/rest/?method=flickr.interestingness.getList&api_key=" + _FLICKR_API_KEY;
    private string _url = _INTERESTING;
    #endregion
    #region Ctor
    public RSSFeed()
    {

    }
    #endregion
    #region Public Methods
    public List<PhotoInfo> LoadPictures(int pageIndex, int numOfImageToFetch)
    {
        try
        {
            var xraw = XElement.Load(_url);
            var xroot = XElement.Parse(xraw.ToString());
            var photos = (from photo in xroot.Element("photos").Elements("photo")
                          select new PhotoInfo
                          {
                              Id = (string)photo.Attribute("id"),
                              Owner = (string)photo.Attribute("owner"),
                              Title = (string)photo.Attribute("title"),
                              Secret = (string)photo.Attribute("secret"),
                              Server = (string)photo.Attribute("server"),
                              Farm = (string)photo.Attribute("farm")
                          }).Skip(pageIndex * numOfImageToFetch).Take(numOfImageToFetch);

            return photos.ToList<PhotoInfo>();
        }
        catch
        {
            return null;
        }
    }
    #endregion
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions