using System.Net;
using System.Text.Json;
using System.Text.RegularExpressions;
using XFEExtension.NetCore.AutoImplement;
using XFEExtension.NetCore.DelegateExtension;
using XFEExtension.NetCore.ServerInteractive.Exceptions;
using XFEExtension.NetCore.ServerInteractive.Interfaces.Requester;
using XFEExtension.NetCore.ServerInteractive.Models.RequesterModels;
using XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
using XFEExtension.NetCore.ServerInteractive.Utilities.JsonConverter;
namespace XFEExtension.NetCore.ServerInteractive.Utilities.Requester;
///
/// 客户端请求器
///
[CreateImpl]
public abstract class ClientRequester : IRequesterBase
{
private readonly JsonSerializerOptions _jsonSerializerOptions = new();
internal Dictionary> RequestServiceDictionary = [];
internal Dictionary> StandardRequestServiceDictionary = [];
internal List<(string Pattern, Func Factory)> WildcardStandardRequestServiceList = [];
internal Dictionary StandardClientInstanceRequestDictionary = [];
private string _session = string.Empty;
private TableRequester? _tableRequester;
///
public string RequestAddress { get; set; } = string.Empty;
///
public string Session
{
get => _session;
set
{
_session = value;
if (TableRequester is not null)
TableRequester.Session = value;
}
}
///
public string DeviceInfo { get; set; } = string.Empty;
///
/// 表格请求器(如需使用表格相关功能,请通过构建器添加WithTableRequester实例并赋值此属性)
///
public TableRequester? TableRequester
{
get => _tableRequester;
set
{
_tableRequester = value;
if (_tableRequester is null) return;
if (_tableRequester.RequestAddress.Length == 0)
_tableRequester.RequestAddress = RequestAddress;
if (_tableRequester.DeviceInfo.Length == 0)
_tableRequester.DeviceInfo = DeviceInfo;
if (_tableRequester.Session.Length == 0)
_tableRequester.Session = Session;
}
}
///
public event XFEEventHandler