當前位置: 首頁>>代碼示例>>C#>>正文


C# RestClient.Put方法代碼示例

本文整理匯總了C#中RestSharp.RestClient.Put方法的典型用法代碼示例。如果您正苦於以下問題:C# RestClient.Put方法的具體用法?C# RestClient.Put怎麽用?C# RestClient.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RestSharp.RestClient的用法示例。


在下文中一共展示了RestClient.Put方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            var appName = string.Empty;
            var hostName = string.Empty;
            var help = false;

            var p = new OptionSet
                {
                    {"app=", v => appName = v},
                    {"host=", v => hostName = v},
                    {"h|?|help", v => help = v != null},
                };
            p.Parse(args);

            if (help || string.IsNullOrWhiteSpace(appName) || string.IsNullOrWhiteSpace(hostName))
            {
                p.WriteOptionDescriptions(Console.Out);
                return;
            }

            var restClient = new RestClient("http://" + hostName + ":9000");
            var request = new RestRequest("/api/v1/apps/" + appName, Method.PUT);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(new { @null = string.Empty });
            var response = restClient.Put(request);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                Console.WriteLine("'{0}' deployment started remotely on '{1}'.", appName, hostName);
            }
        }
開發者ID:repne,項目名稱:deployd-micro,代碼行數:31,代碼來源:Program.cs

示例2: Run

 public IRestResponse Run(Step step, ScenarioContext context)
 {
     var apiPostStep = (ApiPutStep)step;
     var client = new RestClient(apiPostStep.Host);
     var restRequest = BuildRequest(apiPostStep);
     restRequest.AddBody(apiPostStep.RequestPayload);
     return client.Put(restRequest);
 }
開發者ID:AcklenAvenue,項目名稱:Pepino,代碼行數:8,代碼來源:ApiPutStepStrategy.cs

示例3: Put

 public ApiStepResult Put(Guid stepId, string host, string resource, string requestPayload)
 {
     DateTime start = DateTime.Now;
     var client = new RestClient(host);
     var restRequest = new RestRequest(resource);
     restRequest.RequestFormat = DataFormat.Json;
     restRequest.AddBody(requestPayload);
     var restResponse = client.Put(restRequest);
     TimeSpan span = DateTime.Now - start;
     return new ApiStepResult(stepId, restResponse.StatusCode, restResponse.Content, _timeProvider.Now(),
         span.TotalMilliseconds);
 }
開發者ID:AcklenAvenue,項目名稱:Pepino,代碼行數:12,代碼來源:RestSharpApiClient.cs

示例4: UpdateRatings

 static void UpdateRatings(string directory, RestClient rest)
 {
     foreach(var file in Directory.GetFiles(directory)) {
         var fileInfo = new FileInfo (file);
         var bggId = fileInfo.Name.Replace (".json", "");
         var req = new RestRequest ("/topic/boardgames/bgg/" + bggId + "/rating/update");
         Console.WriteLine (req.Resource);
         var resp = rest.Put (req);
         Console.WriteLine (resp.StatusCode);
         Console.WriteLine (resp.Content);
         Console.WriteLine ();
     }
 }
開發者ID:bennidhamma,項目名稱:bgg_uploader,代碼行數:13,代碼來源:Program.cs

示例5: SyncGameInfo

 static void SyncGameInfo(string directory, RestClient rest)
 {
     foreach (var file in Directory.GetFiles (directory)) {
         var info = new FileInfo (file);
         var request = new RestRequest ("/topic/boardgames/bgg/" + info.Name.Replace (".json", ""), Method.PUT);
         Console.WriteLine (request.Resource);
         request.AddParameter ("text/json", File.ReadAllText (file), ParameterType.RequestBody);
         Console.WriteLine ("Putting json from " + file);
         var resp = rest.Put (request);
         Console.WriteLine (resp.StatusCode);
         Console.WriteLine (resp.Content);
     }
 }
開發者ID:bennidhamma,項目名稱:bgg_uploader,代碼行數:13,代碼來源:Program.cs

示例6: SyncRatings

        static void SyncRatings(string directory, RestClient rest)
        {
            foreach(var file in Directory.GetFiles(directory)) {
                var fileInfo = new FileInfo (file);
                var bggId = fileInfo.Name.Replace (".json", "");
                foreach (var line in File.ReadLines(file)) {
                    var req = new RestRequest ("/topic/boardgames/bgg/" + bggId + "/rating");
                    req.AddParameter ("text/json", line, ParameterType.RequestBody);
                    Console.WriteLine (req.Resource);
                    var resp = rest.Put (req);
                    Console.WriteLine (resp.StatusCode);
                    Console.WriteLine (resp.Content);
                    Console.WriteLine ();

                    if (resp.StatusCode == System.Net.HttpStatusCode.InternalServerError) {
                        break;
                    }
                }
            }
        }
開發者ID:bennidhamma,項目名稱:bgg_uploader,代碼行數:20,代碼來源:Program.cs


注:本文中的RestSharp.RestClient.Put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。