public void GetDataAsync <T>(string uri) { string api = Application.Current.Resources["api"] as string;//"http://localhost:27795/";// WebClient webClient = new WebClient(); webClient.DownloadStringCompleted += (o, e) => { T t = JsonConvert.DeserializeObject <T>(e.Result); if (this.GetDataCompleted != null) { GetDataCompletedEventArgs args = new GetDataCompletedEventArgs(); args.DataResult = t; this.GetDataCompleted(this, args); } }; webClient.DownloadStringAsync(new Uri(api + uri)); }
public void GetDataAsync <T>(string uri) { //string api = "http://192.168.0.196:8088/";//Application.Current.Resources["api"] as string;// //string api = "http://192.168.0.188:8084/";//Application.Current.Resources["api"] as string;// //192.168.0.188:8084 WebClient webClient = new WebClient(); webClient.DownloadStringCompleted += (o, e) => { T t = JsonConvert.DeserializeObject <T>(e.Result); if (this.GetDataCompleted != null) { GetDataCompletedEventArgs args = new GetDataCompletedEventArgs(); args.DataResult = t; this.GetDataCompleted(this, args); } }; webClient.DownloadStringAsync(new Uri(uri)); }