Skip to content

Instantly share code, notes, and snippets.

@renatocantarino
Created July 21, 2013 18:23
Show Gist options
  • Save renatocantarino/6049404 to your computer and use it in GitHub Desktop.
Save renatocantarino/6049404 to your computer and use it in GitHub Desktop.
Helper
using System;
using System.Net;
namespace OpenMVC.Helpers
{
public class Builder
{
public static T Download_And_Serialize_Data<T>(string url) where T : new()
{
using (var w = new WebClient())
{
var json_data = string.Empty;
try
{
json_data = w.DownloadString(url);
}
catch (Exception)
{
}
return !string.IsNullOrEmpty(json_data) ? Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json_data) : new T();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment