-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md.saved.bak
More file actions
34 lines (30 loc) · 968 Bytes
/
README.md.saved.bak
File metadata and controls
34 lines (30 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
### 简介
RestSharpHelper是一个使用RestSharp项目,作为二次封装,方便集成Api调用的辅助类,同时提供在Api调用各阶段事件回调和返回数据二次处理。
### 使用方法
下面以网站 [jsonplaceholder.typicode.com/](https://jsonplaceholder.typicode.com/) 的todo数据为例示例:
```csharp
class Program
{
public static void Main(string[] args)
{
var restSharpHelper = GetRestSharpHelper();
var result = restSharpHelper.GetAsync<Todo>("/todos/1");
result.ContinueWith(p =>
{
Assert.AreEqual(1, p.Result.id);
});
result.Wait();
}
private static RestSharpHelper GetRestSharpHelper()
{
return new RestSharpHelper("https://jsonplaceholder.typicode.com");
}
}
public class Todo
{
public int userId { get; set; }
public int id { get; set; }
public string title { get; set; }
public bool completed { get; set; }
}
```