Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.