XieTongClient.cs 991 B

1234567891011121314151617181920212223242526
  1. using Microsoft.Extensions.DependencyInjection;
  2. using Sharing.Province.Dtos;
  3. using XF.Domain.Dependency;
  4. namespace Sharing.Province;
  5. public class XieTongClient : ProvinceClient, ISingletonDependency, ISelfDependency
  6. {
  7. private readonly IServiceScopeFactory _scopeFactory;
  8. public XieTongClient(IServiceScopeFactory scopeFactory) : base(scopeFactory)
  9. {
  10. _scopeFactory = scopeFactory;
  11. }
  12. public Task<TResponse?> RequestAsync<TRequest, TResponse>(TRequest request, CancellationToken cancellationToken)
  13. where TRequest : IProvinceRequest, new()
  14. {
  15. using var scope = _scopeFactory.CreateScope();
  16. var provider = scope.ServiceProvider;
  17. var channelconfigManager = provider.GetRequiredService<IChannelConfigurationManager>();
  18. var configProvince = channelconfigManager.GetConfigurationProvince();
  19. return base.RequestAsync<TRequest, TResponse>(request, configProvince.XieTong, configProvince, cancellationToken);
  20. }
  21. }