當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。