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


C# RestClient.ExecuteGetTaskAsync方法代码示例

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


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

示例1: IsValidKey

        public async Task<bool> IsValidKey(string key)
        {
            try
            {
                var client = new RestClient("http://" + _serverAdress);
                var request = new RestRequest("getProductKeyValid.php", Method.GET);
                request.AddParameter("productkeys_Key", key);

                request.Timeout = 5000;
                IRestResponse response = await client.ExecuteGetTaskAsync(request);
                //only throws the exception. Let target choose what to do
                if (response.ErrorException != null)
                {
                    throw response.ErrorException;
                }
                var model = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(response.Content);
                //if string equals "1" the key is not activated yet
                if (model.Equals("1"))
                    return true;
                return false;
            }
            catch (Exception e)
            {
                return false;
            }
        }
开发者ID:Kundentelefon,项目名称:SMK,代码行数:26,代码来源:DataAccessMySqlPhp.cs

示例2: Words

        public static List<string> Words(int x, int y)
        {
            var words = new List<string> {
                "cars", "card", "cardboard", "carnival",
                "cartoon", "cat", "cats", "cow" };

            var client = new RestClient("http://randomtextgenerator.com/");
            var request = new RestRequest("", Method.GET);
            for (int J = 0; J < x; J++)
            {
                var ts = new List<Task<IRestResponse>>();
                for (int i = 0; i < y; i++)
                {
                    ts.Add(client.ExecuteGetTaskAsync(request));
                }
                foreach (var t in ts)
                {
                    t.Wait();
                    int p1 = t.Result.Content.IndexOf("textarea");
                    int p2 = t.Result.Content.LastIndexOf("textarea");
                    if (p1 < p2)
                    {
                        p1 += 10; p2 -= 10;
                        string parag = t.Result.Content.Substring(p1, p2 - p1);
                        foreach (var word in parag.Split(' '))
                        {
                            if (!word.Contains("\\") && !word.Contains(">") && !word.Contains("<"))
                                words.Add(word.ToLower().Trim());
                        }
                    }
                }
            }
            words.Add("caterpillar");
            return words;
        }
开发者ID:heldersepu,项目名称:csharp-proj,代码行数:35,代码来源:Random.cs

示例3: RequestProductFromProductCatalogue

 private static async Task<IRestResponse> RequestProductFromProductCatalogue(int[] productCatalogueIds)
 {
     var productsResource = string.Format(
       getProductPathTemplate, string.Join(",", productCatalogueIds));
     var httpClient = new RestClient(productCatalogueBaseUrl);
     var request = new RestRequest(productsResource);
     var response = await httpClient.ExecuteGetTaskAsync(request);
     return response;
 }
开发者ID:rinckd,项目名称:angular2,代码行数:9,代码来源:ProductCatalogClient.cs

示例4: GetCampaigns

 public static async Task<IRestResponse<List<Dictionary<string, string>>>> GetCampaigns()
 {
     var client = new RestClient(SiteRealtimeResource.SiteRealtimeDataClient);
     // find vaild sites' id of the designed user
     var request = new RestRequest(SiteRealtimeResource.SiteRealtimeUserRequest, Method.GET);
     request.AddParameter("access_token", User.UserToken.Access_Token);
     //var resp = client.Execute<List<Dictionary<string,string>>>(request);
     return await client.ExecuteGetTaskAsync<List<Dictionary<string, string>>>(request);
 }
开发者ID:heyixiaoran,项目名称:BoardClient,代码行数:9,代码来源:SiteRealtimeService.cs

示例5: DownloadNoIntroDat

        private async static Task DownloadNoIntroDat(string sel_s, int delay=0)
        {
            if (delay > 0)
            {
                Console.WriteLine("[WARN] Must wait " + (delay / 1000 / 60).ToString() + " minutes due to throttling.");
                await Task.Delay(delay);
            }
            Console.WriteLine("[INFO] Downloading " + sel_s.Replace('+', ' '));
            var cookies = new CookieContainer();
            var client = new RestClient("http://datomatic.no-intro.org/?page=download&fun=xml"); //Download the P/Clone
            client.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36";
            client.CookieContainer = cookies; //DAT-o-MATIC relies on cookies
            Console.WriteLine("[INFO] Waiting 1 minute to avoid throttling");
            await Task.Delay(60000);
            await client.ExecuteGetTaskAsync(new RestRequest()); //Save the session cookie
            var setSystemRequest = new RestRequest(Method.POST);
            setSystemRequest.AddParameter("application/x-www-form-urlencoded", "sel_s="+sel_s, ParameterType.RequestBody);
            setSystemRequest.AddHeader("DNT", "1");
            setSystemRequest.AddHeader("Referer", "http://datomatic.no-intro.org/index.php?page=download");
            setSystemRequest.AddHeader("Host", "datomatic.no-intro.org");
            setSystemRequest.AddHeader("Cache-Control", "max-age=0");
            Console.WriteLine("[INFO] Waiting 1 minute to avoid throttling");
            await Task.Delay(60000);
            await client.ExecutePostTaskAsync(setSystemRequest); //POST the system.
           
            var downloadRequest = new RestRequest(Method.POST);
            downloadRequest.AddParameter("application/x-www-form-urlencoded", "Download=Download", ParameterType.RequestBody);
            downloadRequest.AddHeader("DNT", "1");
            downloadRequest.AddHeader("Referer", "http://datomatic.no-intro.org/index.php?page=download");
            downloadRequest.AddHeader("Host", "datomatic.no-intro.org");
            downloadRequest.AddHeader("Cache-Control", "max-age=0");
            Console.WriteLine("[INFO] Waiting 1 minute to avoid throttling");

            await Task.Delay(60000);
            var response = await client.ExecuteTaskAsync(downloadRequest); //POST the download request
            if (response.ResponseUri.OriginalString.StartsWith("http://datomatic.no-intro.org/index.php?page=message"))
            {
                Console.WriteLine("[WARN] Throttle detected, must wait 5 minutes before retrying");
                await download.DownloadNoIntroDat(sel_s, delay + 600000);
            }
            else
            {
                File.WriteAllBytes(sel_s.Replace('+', ' ') + ".zip", response.RawBytes);
                using (var package = new ZipArchive(new MemoryStream(response.RawBytes)))
                {
                    foreach (var entry in package.Entries)
                    {
                        if (Path.GetExtension(entry.FullName) == ".dat")
                        {
                            entry.ExtractToFile("nointro_" + entry.Name, true);
                        }
                    }
                }
                Console.WriteLine("[INFO] Download Complete");
            }
            
        }
开发者ID:SnowflakePowered,项目名称:awagame,代码行数:57,代码来源:download.cs

示例6: Download

 public async Task<IRestResponse> Download(string baseUrl, int timeout = 10000)
 {
     var restClient = new RestClient(baseUrl) { Timeout = timeout };
     if (!string.IsNullOrEmpty(_settings.GetDefaultProxy()))
     {
         restClient.Proxy = new WebProxy(new Uri(_settings.GetDefaultProxy()));
     }
     var restResponse = await restClient.ExecuteGetTaskAsync(new RestRequest());
     
     return restResponse;
 }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:11,代码来源:HttpLookup.cs

示例7: GetLatestQuestion

        public async Task<IRestResponse<Rootobject>> GetLatestQuestion()
        {
            var client = new RestClient(url);
            client.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36";
            var request = new RestRequest(Method.GET);
            // request.AddParameter("name", "value"); // adds to POST or URL querystring based on Method
            // request.AddUrlSegment("id", args);
            var response = await client.ExecuteGetTaskAsync<Rootobject>(request);

            return response;
        }
开发者ID:vendettamit,项目名称:stackoverflowclient,代码行数:11,代码来源:ServiceAPI.cs

示例8: GetLights

        public async Task<IEnumerable<LifxHttpLight>> GetLights()
        {
            var client = new RestClient(BaseUrl);
            var request = new RestRequest("v1/lights/all");
            request.AddHeader("Authorization", $"Bearer {_token}");

            var response = await client.ExecuteGetTaskAsync<List<LifxHttpLight>>(request);
            if (response?.ErrorException != null)
            {
                throw response.ErrorException;
            }

            return response?.Data;
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:14,代码来源:LifxHttpClient.cs

示例9: Find

        public async Task<TranslateResult> Find(TranslateRequest translateRequest)
        {
            if (!configuration.IsAppropriateForTranslation(TranslatorType))
                return new TranslateResult(false, new Maybe<string>());

            var address = string.Format(configuration.GoogleTranslateUrl, configuration.ToLanguageExtension, configuration.ToLanguageExtension, translateRequest.CurrentText);

            var client = new RestClient(address);
            var request = new RestRequest(Method.GET);
            var compositeMean = await client.ExecuteGetTaskAsync(request);
            var organizer = meanOrganizerFactory.GetMeanOrganizers().First(x => x.TranslatorType == TranslatorType.GOOGLE);
            var mean = await organizer.OrganizeMean(compositeMean.Content);

            return new TranslateResult(true, mean);
        }
开发者ID:WildGenie,项目名称:DynamicTranslator,代码行数:15,代码来源:GoogleTranslateFinder.cs

示例10: DetectLanguage

        public async Task<string> DetectLanguage(string text)
        {
            var client = new RestClient(string.Format(configuration.GoogleTranslateUrl, configuration.ToLanguageExtension, configuration.ToLanguageExtension, text));
            var request = new RestRequest(Method.GET);
            var response = await client.ExecuteGetTaskAsync(request);

            var result = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content);

            if (result?["src"] != null)
            {
                return result["src"].ToString();
            }

            return configuration.FromLanguageExtension;
        }
开发者ID:WildGenie,项目名称:DynamicTranslator,代码行数:15,代码来源:GoogleLanguageDetector.cs

示例11: GetVariableAsync

		public static async Task<VariableResponse> GetVariableAsync(string variable)
		{
			var request = String.Format("https://api.spark.io/v1/devices/{0}/{2}?access_token={1}",Configuration.DeviceID,Configuration.AccessToken,variable);
			var client = new RestClient ();

			var req = new RestRequest (request);
			var response = await client.ExecuteGetTaskAsync (req);

			if (response.StatusCode == HttpStatusCode.OK) {
				return JsonConvert.DeserializeObject<VariableResponse> (response.Content);
			}

			return null;

		}
开发者ID:yonglehou,项目名称:sparksharp-1,代码行数:15,代码来源:RESTCore.cs

示例12: GetRealtimeData

        public static async Task<List<TrackRealtimeData>> GetRealtimeData(string campaignId, string startDate, string endDate, string dimensions, string metrics, string maxResults, string dataOrderBy)
        {
            var client = new RestClient(TrackRealtimeResource.TrackRealtimeDataClient);
            var convertedDimension = FormatDimensions(dimensions);
            var request = new RestRequest(string.Format(TrackRealtimeResource.TrackRealtimeDataRequest, campaignId, startDate, endDate, convertedDimension, metrics, maxResults, dataOrderBy, User.UserToken.Access_Token), Method.GET);

            var response = await client.ExecuteGetTaskAsync<List<TrackRealtimeData>>(request);
            if(response.StatusCode != HttpStatusCode.OK)
            {
                return null;
            }

            var trackRealtimeData = response.Data;

            TrackRealtimeCampaignRequest.Singleton.InitialRequest(TrackAnalysisReportResource.TrackAnalysisDataClient, User.UserToken.Access_Token);
            var campaigns = await TrackRealtimeCampaignRequest.Singleton.GetCampaigns();

            TrackRealtimeExtensionRequest.Singleton.InitialRequest(User.UserToken.Access_Token);
            var placement = await TrackRealtimeExtensionRequest.Singleton.GetPlacementNames(campaignId);
            var creative = await TrackRealtimeExtensionRequest.Singleton.GetCreativeNames(campaignId);
            foreach(var item in trackRealtimeData)
            {
                item.Campaigns = campaignId;
                item.CampaignsName = campaigns[campaignId];
                if(item.Media != 0)
                {
                    item.MediaName = await TrackRealtimeExtensionRequest.Singleton.GetMediaName(item.Media);
                }

                if(item.Placement != 0)
                {
                    string placementId = item.Placement.ToString();
                    item.PlacementName = placement[placementId];
                }

                if(item.Creative != 0)
                {
                    string creativeId = item.Creative.ToString();
                    item.CreativeName = creative[creativeId];
                }
                else
                {
                    item.CreativeName = "默认创意";
                }
            }

            return trackRealtimeData;
        }
开发者ID:heyixiaoran,项目名称:BoardClient,代码行数:48,代码来源:TrackRealtimeService.cs

示例13: CheckConnectedAsync

        public async Task<bool> CheckConnectedAsync()
        {
            // BAD: Phoning home.
            var client = new RestClient("https://lokun.is/");
            var request = new RestRequest("connected.json");
            request.AddHeader("User-Agent", "lokun-client0.2");
            
            var response = await client.ExecuteGetTaskAsync<Connected>(request);

            if (response.Data == null)
            {
                return false;
            }
            else
            {
                return response.Data.connected;
            }
        }
开发者ID:benediktkr,项目名称:lokun-client,代码行数:18,代码来源:Lokun.cs

示例14: ListTokensAsync

		//	var tokens = Spark.RESTCore.ListTokensAsync ("user", "password").Result;

		public static async Task<List<TokenResponse>> ListTokensAsync(string email, string secret)
		{
			var request = String.Format("https://api.spark.io/v1/access_tokens");
			var client = new RestClient ();

			string base64credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes(String.Format("{0}:{1}", email, secret)));

			var req = new RestRequest (request);
			req.AddHeader ("Authorization", String.Format ("Basic {0}", base64credentials));
			var response = await client.ExecuteGetTaskAsync (req);

			if (response.StatusCode == HttpStatusCode.OK) {
				List<TokenResponse> responses = (List<TokenResponse>) JsonConvert.DeserializeObject(response.Content,typeof(List<TokenResponse>));
				return responses;
			}

			return null;
		}
开发者ID:yonglehou,项目名称:sparksharp-1,代码行数:20,代码来源:RESTCore.cs

示例15: DetectLanguage

        public async Task<string> DetectLanguage(string text)
        {
            var client = new RestClient(string.Format(configuration.YandexDetectTextUrl, text));
            var request = new RestRequest(Method.GET);
            request.AddHeader("postman-token", "97e3784e-2f4d-822f-d735-1a96aba9ffee");
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("accept-language", "en-US,en;q=0.8,tr;q=0.6");
            request.AddHeader("accept-encoding", "gzip, deflate, sdch");
            request.AddHeader("referer", "https//ceviri.yandex.com.tr/?text=h&lang=de-tr");
            request.AddHeader("accept", "*/*");
            request.AddHeader("origin", "https//ceviri.yandex.com.tr");
            request.AddHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36");
            var response = await client.ExecuteGetTaskAsync(request);
            var result = JsonConvert.DeserializeObject<YandexDetectResponse>(response.Content);

            if (result != null && string.IsNullOrEmpty(result.Lang))
            {
                return result.Lang;
            }

            return configuration.ToLanguageExtension;
        }
开发者ID:WildGenie,项目名称:DynamicTranslator,代码行数:22,代码来源:YandexLanguageDetector.cs


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