/// <summary>
/// Retrieve all of a users galleries
/// </summary>
/// <param name="cookieHeader">A String representation of the session id cookie</param>
public void MyGalleries(String cookieHeader)
{
if (String.IsNullOrEmpty(cookieHeader))
{
throw new ArgumentException("Cookie Header cannot be null or empty");
}
CookieAwareWebClient client = this.CreateAndSetupWebClient();
client.setCookieHeader(new Uri(BASE_URL), cookieHeader);
client.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
Debug.WriteLine("MyGalleries operation failed: " + e.Error.Message);
this.TriggerGetItemsFailed(e.Error);
#if !WINDOWS_PHONE
client.Dispose();
#endif
return;
}
MyGalleriesResult result = JsonConvert.DeserializeObject <MyGalleriesResult>(e.Result);
Debug.WriteLine("MyGalleries operation successful: " + result);
this.TriggerMyGalleriesComplete(result);
#if !WINDOWS_PHONE
client.Dispose();
#endif
};
try
{
ThreadPool.QueueUserWorkItem((object state) =>
{
try
{
client.DownloadStringAsync(MY_GALLERIES_URL);
}
catch (WebException e)
{
Debug.WriteLine("Failed to access MyGalleries API: " + e.Message);
this.TriggerGetItemsFailed(e);
#if !WINDOWS_PHONE
client.Dispose();
#endif
}
});
}
catch (Exception e)
{
Debug.WriteLine("Failed to submit task to thread pool: " + e.Message);
this.TriggerGetItemsFailed(e);
#if !WINDOWS_PHONE
client.Dispose();
#endif
}
}