当前位置: 首页>>代码示例>>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;未经允许,请勿转载。