using System.Text.Json; using Microsoft.Extensions.Configuration; using Persistence.Client.Helpers; using Refit; namespace Persistence.Client { /// /// Фабрика клиентов для доступа к Persistence - сервису /// public class PersistenceClientFactory { private static readonly JsonSerializerOptions JsonSerializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true }; private static readonly RefitSettings RefitSettings = new(new SystemTextJsonContentSerializer(JsonSerializerOptions)); private HttpClient httpClient; public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IConfiguration configuration) { this.httpClient = httpClientFactory.CreateClient(); httpClient.Authorize(configuration); } public T GetClient() { return RestService.For(httpClient, RefitSettings); } } }