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


C# RestClient.ExecuteTask方法代码示例

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


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

示例1: Feed

        private async Task<QuestionSummaryResponse> Feed(string feed,int skip, int take)
        {
            RestClient client = new RestClient(AppSettings.ApiUri);

            RestRequest request = new RestRequest("questions/" + feed, Method.GET);
            request.AddParameter("skip", skip);
            request.AddParameter("take", take);

            return await client.ExecuteTask<QuestionSummaryResponse>(request);
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:10,代码来源:QuestionRestService.cs

示例2: SearchByTag

        public async Task<QuestionSummaryResponse> SearchByTag(string tag, int skip, int take)
        {
            RestClient client = new RestClient(AppSettings.ApiUri);

            RestRequest request = new RestRequest("search/tagged/{tag}", Method.GET);
            request.AddParameter("skip", skip);
            request.AddParameter("take", take);
            request.AddParameter("tag", tag, ParameterType.UrlSegment);

            return await client.ExecuteTask<QuestionSummaryResponse>(request);
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:11,代码来源:SearchRestService.cs

示例3: GetForecast

        public static Task<List<LiveTileWeatherResponse>> GetForecast(GeoLocationCity city, DateTime date)
        {
            if (city == null)
                throw new ArgumentNullException("city");

            var client = new RestClient("http://www.dr.dk/tjenester/drvejret/");
            var request = new RestRequest();
            request.DateFormat = "yyyyMMddHHmm";
            request.Resource = "Forecast/{latitude}/{longitude}/{date}";
            request.AddUrlSegment("latitude", city.Location.Latitude.ToString(CultureInfo.InvariantCulture));
            request.AddUrlSegment("longitude", city.Location.Longitude.ToString(CultureInfo.InvariantCulture));
            request.AddUrlSegment("date", date.ToString("yyyyMMdd"));

            return client.ExecuteTask<List<LiveTileWeatherResponse>>(request);
        }
开发者ID:wooda77,项目名称:DMI-Byvejr,代码行数:15,代码来源:LiveTileWeatherProvider.cs

示例4: GetAccountDataAsync

        public static async Task<AccountData[]> GetAccountDataAsync(string username, string password)
        {
            var baseUrl = "https://wwws.mint.com";
            var cookieContainer = new CookieContainer();
            
            var userClient = new RestClient(baseUrl);
            userClient.CookieContainer = cookieContainer;
            var userRequest = new RestRequest("getUserPod.xevent", Method.POST);
            userRequest.AddParameter("username", username);

            await userClient.ExecuteTask(userRequest);

            var loginClient = new RestClient(baseUrl);
            loginClient.CookieContainer = cookieContainer;
            loginClient.Authenticator = new SimpleAuthenticator("username", username, "password", password);
            loginClient.FollowRedirects = true;
            var loginRequest = new RestRequest("loginUserSubmit.xevent", Method.POST);
            loginRequest.AddParameter("task", "L");

            var loginResponse = await loginClient.ExecuteTask(loginRequest);

            if (loginResponse.ResponseUri.ToString().EndsWith("login.event?task=L"))
            {
                throw new AuthenticationException("Invalid credentials.");
            }

            var tokenRegex = new Regex(@"\<input\stype=""hidden""\sid=""javascript-token""\svalue=""(?<Token>.*?)""/\>");
            var tokenMatch = tokenRegex.Match(loginResponse.Content);
            if (tokenMatch == null || tokenMatch.Groups["Token"] == null || String.IsNullOrEmpty(tokenMatch.Groups["Token"].Value))
            {
                throw new Exception("The 'javascript-token' value was not found.");
            }

            var token = tokenMatch.Groups["Token"].Value;

            var getAccountsClient = new RestClient(baseUrl);
            getAccountsClient.CookieContainer = cookieContainer;
            var getAccountsRequest = new RestRequest("bundledServiceController.xevent?token=" + token, Method.POST);
            getAccountsRequest.AddParameter("input", @"[{""args"":{""types"":[""BANK"",""CREDIT"",""INVESTMENT"",""LOAN"",""MORTGAGE"",""OTHER_PROPERTY"",""REAL_ESTATE"",""VEHICLE"",""UNCLASSIFIED""]},""service"":""MintAccountService"",""task"":""getAccountsSorted"",""id"":""accounts""}]", ParameterType.GetOrPost);

            var getAccountsResponse = await getAccountsClient.ExecuteTask(getAccountsRequest);

            dynamic dataObject = JObject.Parse(getAccountsResponse.Content);

            var accountDataList = new List<AccountData>();
            foreach (var accountObject in dataObject["response"]["accounts"]["response"])
            {
                if ((string)accountObject["accountStatus"] != "1")
                {
                    continue;
                }

                var accountData = new AccountData();
                accountData.AccountType = (string)accountObject["accountType"];
                accountData.Name = (string)accountObject["accountName"];
                accountData.InstitutionName = (string)accountObject["fiName"];
                accountData.Balance = GetBalance((decimal)accountObject["currentBalance"], (string)accountObject["accountType"]);
                accountData.LastUpdated = new DateTime((long)accountObject["lastUpdated"] * 10000 + 621355968000000000);
                accountData.LoginStatus = GetLoginStatus((string)accountObject["fiLoginStatus"]);
                
                accountDataList.Add(accountData);
            }

            return accountDataList.ToArray();
        }
开发者ID:shaftware,项目名称:Mojito,代码行数:65,代码来源:AppServices.cs


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