README
来源:互联网 发布:win8优化驱动器要几遍 编辑:程序博客网 时间:2024/06/05 08:38
RestSharp - Simple .NET REST Client
Official Site/Blog - @RestSharp
License: Apache License 2.0
Features
- Supports .NET 3.5+, Silverlight 5, Windows Phone 8, Mono, MonoTouch, Mono for Android
- Easy installation using NuGet for most .NET flavors
- Supports strong naming using NuGet for most .NET flavors
- Automatic XML and JSON deserialization
- Supports custom serialization and deserialization via ISerializer and IDeserializer
- Fuzzy element name matching (‘product_id’ in XML/JSON will match C# property named ‘ProductId’)
- Automatic detection of type of content returned
- GET, POST, PUT, HEAD, OPTIONS, DELETE supported
- Other non-standard HTTP methods also supported
- oAuth 1, oAuth 2, Basic, NTLM and Parameter-based Authenticators included
- Supports custom authentication schemes via IAuthenticator
- Multi-part form/file uploads
- T4 Helper to generate C# classes from an XML document
var client = new RestClient("http://example.com");// client.Authenticator = new HttpBasicAuthenticator(username, password);var request = new RestRequest("resource/{id}", Method.POST);request.AddParameter("name", "value"); // adds to POST or URL querystring based on Methodrequest.AddUrlSegment("id", "123"); // replaces matching token in request.Resource// add parameters for all properties on an objectrequest.AddObject(object);// or just whitelisted propertiesrequest.AddObject(object, "PersonId", "Name", ...);// easily add HTTP Headersrequest.AddHeader("header", "value");// add files to upload (works with compatible verbs)request.AddFile("file", path);// execute the requestIRestResponse response = client.Execute(request);var content = response.Content; // raw content as string// or automatically deserialize result// return content type is sniffed but can be explicitly set via RestClient.AddHandler();IRestResponse<Person> response2 = client.Execute<Person>(request);var name = response2.Data.Name;// or download and save file to diskclient.DownloadData(request).SaveAs(path);// easy async supportclient.ExecuteAsync(request, response => { Console.WriteLine(response.Content);});// async with deserializationvar asyncHandle = client.ExecuteAsync<Person>(request, response => { Console.WriteLine(response.Data.Name);});// abort the request on demandasyncHandle.Abort();
阅读全文
0 0
- README
- Readme
- README
- README
- readme
- readme
- readme
- ReadMe
- ReadMe
- README
- README
- readme
- Readme
- README
- README
- README
- README
- readme
- 【Java】SpringMVC实现多张图片上传实例
- 算法导论程序14-快速排序的随机化版本(Python)
- 二叉排序树数值最接近节点
- 用队列解决杨辉三角问题
- ASP.NET Core HTTP 管道中的那些事儿
- README
- 面试:----maven怎么添加自己的jar包
- Delphi XE10 给地图层上面添加Android原生控件
- 5.24~6.4-Python-语言及其应用-笔记-代码结构
- Android BIN档格式sparse 及 ext4
- 80x86的寻址方式
- 程序员如何快速准备面试中的算法
- ASP.NET Core Kestrel 中使用 HTTPS (SSL)
- SQL游标使用——格式、实例、嵌套