using NCC.JsonSerialization; using System; using System.Collections.Generic; using System.Net.Http; using System.Text; namespace NCC.RemoteRequest { /// /// Http 请求对象组装部件 /// public sealed partial class HttpRequestPart { /// /// 静态缺省请求部件 /// public static HttpRequestPart Default => new(); /// /// 请求地址 /// public string RequestUrl { get; private set; } /// /// Url 地址模板 /// public IDictionary Templates { get; private set; } /// /// 请求方式 /// public HttpMethod Method { get; private set; } /// /// 请求报文头 /// public IDictionary Headers { get; private set; } /// /// 查询参数 /// public IDictionary Queries { get; private set; } /// /// 客户端名称 /// public string ClientName { get; private set; } /// /// 请求报文 Body 参数 /// public object Body { get; private set; } /// /// 请求报文 Body 内容类型 /// public string ContentType { get; private set; } = "application/json"; /// /// 内容编码 /// public Encoding ContentEncoding { get; private set; } = Encoding.UTF8; /// /// 设置 Body Bytes 类型 /// public List<(string Name, byte[] Bytes, string FileName)> BodyBytes { get; private set; } = new List<(string Name, byte[] Bytes, string FileName)>(); /// /// 超时时间(秒) /// public long Timeout { get; private set; } /// /// JSON 序列化提供器 /// public Type JsonSerializerProvider { get; private set; } = typeof(SystemTextJsonSerializerProvider); /// /// JSON 序列化配置选项 /// public object JsonSerializerOptions { get; private set; } /// /// 是否启用模型验证 /// public (bool Enabled, bool IncludeNull) ValidationState { get; private set; } = (false, false); /// /// 构建请求对象拦截器 /// public List> RequestInterceptors { get; private set; } = new List>(); /// /// 创建客户端对象拦截器 /// public List> HttpClientInterceptors { get; private set; } = new List>(); /// /// 请求成功拦截器 /// public List> ResponseInterceptors { get; private set; } = new List>(); /// /// 请求异常拦截器 /// public List> ExceptionInterceptors { get; private set; } = new List>(); /// /// 设置请求作用域 /// public IServiceProvider RequestScoped { get; private set; } /// /// 设置重试策略 /// public (int NumRetries, int RetryTimeout)? RetryPolicy { get; private set; } } }