Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Created February 5, 2014 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/8823781 to your computer and use it in GitHub Desktop.
Save jeffpatton1971/8823781 to your computer and use it in GitHub Desktop.
Edmunds json code
public static T GetEdmundsContent<T>(string url) where T : new()
{
using (var client = new WebClient())
{
var jsonData = string.Empty;
try
{
Sleep(1000);
jsonData = client.DownloadString(url);
}
catch (Exception ex)
{
throw ex;
}
return !string.IsNullOrEmpty(jsonData) ? JsonConvert.DeserializeObject<T>(jsonData) : new T();
}
}
//public static T[] GetEdmundsContents<T>(string url) where T : new()
//{
// using (var client = new WebClient())
// {
// var jsonData = string.Empty;
// try
// {
// Sleep(1000);
// jsonData = client.DownloadString(url);
// }
// catch (Exception ex)
// {
// throw ex;
// }
// return !string.IsNullOrEmpty(jsonData) ? JsonConvert.DeserializeObject<T[]>(jsonData) : new T();
// }
//}
static void Sleep(int ms)
{
new System.Threading.ManualResetEvent(false).WaitOne(ms);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment