Избавиться от System.Configuration.ConfigurationManager в DD.Persistence.Client

This commit is contained in:
Оля Бизюкова 2025-02-04 12:25:18 +05:00
parent d67eaca0e6
commit e15692c2ad
3 changed files with 22 additions and 4 deletions

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DD.Persistence.Client.CustomExceptions;
/// <summary>
/// Ошибка, которая выбрасывается в случае отсутствия необходимого свойства в appsettings.json
/// </summary>
public class AppSettingsPropertyNotFoundException : Exception
{
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public AppSettingsPropertyNotFoundException(string message)
: base(message) { }
}

View File

@ -52,7 +52,6 @@
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.3.0" />
<PackageReference Include="Refit" Version="8.0.0" />
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
</ItemGroup>

View File

@ -1,9 +1,8 @@
using DD.Persistence.Client.Clients.Interfaces.Refit;
using DD.Persistence.Client.Helpers;
using DD.Persistence.Client.CustomExceptions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Refit;
using System.Configuration;
using System.Text.Json;
namespace DD.Persistence.Client;
@ -26,7 +25,7 @@ public class RefitClientFactory<T> : IRefitClientFactory<T> where T : IRefitClie
var baseUrl = configuration.GetSection("ClientUrl").Get<string>();
if (String.IsNullOrEmpty(baseUrl))
{
var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса.");
var exception = new AppSettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса.");
logger.LogError(exception.Message);