private void OnPhotoSetPhotosReturned(object sender, GetPhotoSetPhotosEventArgs e)
        {
            if (!Cinderella.CinderellaCore.PhotoSetCache.ContainsKey(e.PhotoSetId))
                return;

            PhotoSet photoset = Cinderella.CinderellaCore.PhotoSetCache[e.PhotoSetId];

            JObject rawJson = JObject.Parse(e.Response);
            JObject rootJson = (JObject)rawJson["photoset"];
            int TotalCount = int.Parse(rootJson["total"].ToString());
            int page = int.Parse(rootJson["page"].ToString());
            int numPages = int.Parse(rootJson["pages"].ToString());
            int perPage = int.Parse(rootJson["perpage"].ToString());

            List<Photo> newPhotos = new List<Photo>();
            foreach (var entry in rootJson["photo"])
            {
                JObject json = (JObject)entry;
                Photo photo = PhotoFactory.PhotoWithJObject(json);

                if (!photoset.Photos.Contains(photo))
                {
                    photoset.Photos.Add(photo);
                    newPhotos.Add(photo);
                }
            }

            // Dispatch event
            PhotoSetPhotosUpdatedEventArgs evt = new PhotoSetPhotosUpdatedEventArgs();
            evt.PhotoSetId = photoset.ResourceId;
            evt.Page = page;
            evt.PageCount = numPages;
            evt.PerPage = perPage;
            evt.NewPhotos = newPhotos;
            PhotoSetPhotosUpdated.DispatchEvent(this, evt);
        }
        public async void GetPhotoSetPhotosAsync(string setId, Dictionary<string, string> parameters = null)
        {
            if (setPhotoFetchingQueue.Contains(setId))
                return;

            setPhotoFetchingQueue.Add(setId);

            string timestamp = DateTimeUtils.GetTimestamp();
            string nonce = Guid.NewGuid().ToString().Replace("-", null);

            Dictionary<string, string> paramDict = new Dictionary<string, string>();
            paramDict["method"] = "flickr.photosets.getPhotos";
            paramDict["format"] = "json";
            paramDict["nojsoncallback"] = "1";
            paramDict["oauth_consumer_key"] = consumerKey;
            paramDict["oauth_nonce"] = nonce;
            paramDict["oauth_signature_method"] = "HMAC-SHA1";
            paramDict["oauth_timestamp"] = timestamp;
            paramDict["oauth_token"] = AccessToken;
            paramDict["oauth_version"] = "1.0";
            paramDict["photoset_id"] = setId;

            if (parameters != null)
            {
                foreach (var entry in parameters)
                {
                    paramDict[entry.Key] = entry.Value;
                }
            }

            paramDict["extras"] = UrlHelper.Encode(commonExtraParameters);

            string paramString = GenerateParamString(paramDict);
            string signature = GenerateSignature("GET", AccessTokenSecret, "https://api.flickr.com/services/rest", paramString);
            string requestUrl = "https://api.flickr.com/services/rest?" + paramString + "&oauth_signature=" + signature;
            HttpWebResponse response = await DispatchRequest("GET", requestUrl, null).ConfigureAwait(false);
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                if(setPhotoFetchingQueue.Contains(setId))
                    setPhotoFetchingQueue.Remove(setId);

                GetPhotoSetPhotosExceptionEventArgs exceptionEvt = null;

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    HandleHTTPException(response);

                    exceptionEvt = new GetPhotoSetPhotosExceptionEventArgs();
                    exceptionEvt.PhotoSetId = setId;
                    PhotoSetPhotosException(this, exceptionEvt);
                    return;
                }

                string jsonString = await reader.ReadToEndAsync().ConfigureAwait(false);
                if (!TryHandleResponseException(jsonString, () => { GetPhotoSetPhotosAsync(setId, parameters); }))
                {
                    exceptionEvt = new GetPhotoSetPhotosExceptionEventArgs();
                    exceptionEvt.PhotoSetId = setId;
                    PhotoSetPhotosException(this, exceptionEvt);
                    return;
                }

                GetPhotoSetPhotosEventArgs args = new GetPhotoSetPhotosEventArgs();
                args.PhotoSetId = setId;
                args.Response = jsonString;
                PhotoSetPhotosReturned.DispatchEvent(this, args);
            }
        }