Created
February 5, 2014 13:39
-
-
Save jeffpatton1971/8823781 to your computer and use it in GitHub Desktop.
Edmunds json code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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