コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: WebAPIHelper.cs プロジェクト: zkg642/JXXZ
        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));
        }