当前位置: 首页>>代码示例>>C#>>正文


C# RestClient.GetAsync方法代码示例

本文整理汇总了C#中RestSharp.RestClient.GetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.GetAsync方法的具体用法?C# RestClient.GetAsync怎么用?C# RestClient.GetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RestSharp.RestClient的用法示例。


在下文中一共展示了RestClient.GetAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetContentAsync

        public Task<string> GetContentAsync(string url)
        {
            var tcs = new TaskCompletionSource<string>();

            try
            {
                var client = new RestClient(url);

                client.GetAsync(new RestRequest(), (response, handle) =>
                {
                    if ((int)response.StatusCode >= 400)
                    {
                        tcs.SetException(new Exception(response.StatusDescription));
                    }
                    else
                    {
                        tcs.SetResult(response.Content);
                    }
                });
            }
            catch (Exception ex)
            {
                tcs.SetException(ex);
            }

            return tcs.Task;
        }
开发者ID:timschlechter,项目名称:akka-demos,代码行数:27,代码来源:Webclient.cs

示例2: DoRequest

    private void DoRequest(string requestUrl) {
        RestClient client = new RestClient(requestUrl);
        RestRequest request = new RestRequest("", Method.GET);
        request.AddHeader("test", "test");

        Debug.Log("Testing url: " + requestUrl);
        IRestResponse response = client.Get(request);
        ValidateResponse(requestUrl, response, false);
        
        client.GetAsync(request, OnResponse);
        
    }
开发者ID:eamonwoortman,项目名称:RestSharp.Unity.Tester,代码行数:12,代码来源:RestSharpTester.cs

示例3: Get

        public static void Get(string format)
        {
            var id = GetSelectedId();

            if (id != Guid.Empty)
            {
                var c = new RestClient(String.Format("{0}/{1}?format={2}", baseUrl, id, format));
                List<UserModel> res = Enumerable.Empty<UserModel>().ToList();
                c.GetAsync<List<UserModel>>(CreateRequest(RestSharp.Method.GET, format), (resp, result) =>
                                                                                             {
                                                                                                 res = resp.Data;
                                                                                                 WriteResult("GET", resp);
                                                                                             });
            }
        }
开发者ID:zsschoner,项目名称:WebApiSample,代码行数:15,代码来源:RestSharpClient.cs

示例4: Authenticate

        public void Authenticate()
        {
            var request = new RestRequest("/", Method.GET) { RequestFormat = DataFormat.Json };
            request.AddHeader("api-key", _apiKey);
            var stsClient = new RestClient(BaseSecureUrl)
            {
                Authenticator = new HttpBasicAuthenticator(_userName, _password)
            };

            stsClient.GetAsync<Token>(request,
                                      (response, handle) =>
                                      {
                                          if (response.StatusCode == HttpStatusCode.OK)
                                              if (response.Data != null) _accessToken = response.Data.AccessToken;
                                              else if (response.ErrorException != null)
                                                  throw response.ErrorException;
                                      }
                );
        }
开发者ID:IngageNetworks,项目名称:GhostWriter,代码行数:19,代码来源:API.cs

示例5: HttpGetAsync

 public static void HttpGetAsync(this Uri uri, Action<IRestResponse> result)
 {
     if (uri == null)
         return;
     RestClient client = new RestClient(uri);
     RestRequest request = new RestRequest();
     client.GetAsync(request, (restResponse, handle) =>
     {
         result(restResponse);
     });
 }
开发者ID:zhang-xiao-ming,项目名称:RestApiClient,代码行数:11,代码来源:UriExtensions.cs


注:本文中的RestSharp.RestClient.GetAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。