//using MAX.Core.Autofac;
//using MAX.Core.Helpers;
//using System;
//using System.Net;
//using System.Text;
//namespace Store.Client.HttpExtension
//{
// ///
// /// 服务请求公共基类。
// /// 该基类只负责按 Key 获取服务配置以及执行底层 HTTP 请求,不绑定具体业务签名规则。
// ///
// public abstract class ServiceRequestBase
// {
// ///
// /// 服务配置提供器。由 Autofac 通过属性注入。
// ///
// [Autowired]
// protected IServiceConfigProvider ServiceConfigProvider { get; set; }
// ///
// /// 当前请求类使用的服务配置 Key。
// /// 项目 API 可以重写该属性以使用自己的服务地址。
// ///
// protected virtual string ServiceConfigKey => ServiceConfigKeys.Default;
// ///
// /// 获取当前服务配置。
// ///
// protected IApiServerConfig GetServiceConfig()
// {
// return GetServiceConfig(ServiceConfigKey);
// }
// ///
// /// 获取指定 Key 的服务配置。
// ///
// protected IApiServerConfig GetServiceConfig(string serviceConfigKey)
// {
// if (ServiceConfigProvider == null)
// {
// throw new InvalidOperationException("IServiceConfigProvider 未注入,请通过 DI 容器创建请求服务。");
// }
// return ServiceConfigProvider.Get(serviceConfigKey);
// }
// ///
// /// 使用当前 Key 构建服务请求地址。
// ///
// protected string BuildServiceUrl(string urlPath)
// {
// return BuildServiceUrl(ServiceConfigKey, urlPath);
// }
// ///
// /// 使用指定 Key 构建服务请求地址。
// ///
// protected string BuildServiceUrl(string serviceConfigKey, string urlPath)
// {
// IApiServerConfig config = GetServiceConfig(serviceConfigKey);
// return config.Host + "?" + config.ObjUrl + (urlPath ?? string.Empty);
// }
// ///
// /// 获取指定 Key 的基础地址。
// ///
// protected string GetServiceHost(string serviceConfigKey = null)
// {
// IApiServerConfig config = string.IsNullOrWhiteSpace(serviceConfigKey)
// ? GetServiceConfig()
// : GetServiceConfig(serviceConfigKey);
// return config.Host;
// }
// ///
// /// 执行底层 HTTP 请求。
// ///
// protected HttpResult Send(HttpItem item)
// {
// if (item == null)
// {
// throw new ArgumentNullException(nameof(item));
// }
// if (string.IsNullOrWhiteSpace(item.URL))
// {
// throw new ArgumentException("请求地址不能为空。", nameof(item));
// }
// if (!item.URL.StartsWith("http", StringComparison.OrdinalIgnoreCase))
// {
// item.URL = GetServiceConfig().Host + "/" + item.URL.TrimStart('/');
// }
// item.Encoding = Encoding.UTF8;
// HttpResult result = HttpHelper.Request(item);
// if (result.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(result.Html) && result.Html[0] == 65279)
// {
// result.Html = result.Html.Remove(0, 1);
// }
// return result;
// }
// }
//}