-
Notifications
You must be signed in to change notification settings - Fork 0
/
TianRequest.cs
32 lines (28 loc) · 1.01 KB
/
TianRequest.cs
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
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
namespace TianYanCha.SDK
{
public abstract class TianRequest<TResponse> : IRequest<TResponse> where TResponse : TianResponse, new()
{
/// <summary>
/// 获取API名称
/// </summary>
/// <returns></returns>
public abstract string GetApiName();
public virtual IDictionary<string, object> GetParameters()
{
IDictionary<string, object> parameters = null;
if (parameters != null)
return parameters;
var properties = this.GetType().GetProperties();
return properties.ToDictionary(m => ((JsonPropertyAttribute)m.GetCustomAttributes(typeof(JsonPropertyAttribute), false).First()).PropertyName, n => n.GetValue(this, null));
}
/// <summary>
/// 获取请求提交的方法
/// </summary>
/// <returns></returns>
public abstract HttpMethod GetHttpMethod();
}
}