From e15692c2adaecc26da975393dfee6c205126310f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Tue, 4 Feb 2025 12:25:18 +0500 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D0=B7=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=D1=81=D1=8F=20=D0=BE=D1=82=20System.Configuration.Config?= =?UTF-8?q?urationManager=20=D0=B2=20DD.Persistence.Client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettingsPropertyNotFoundException.cs | 20 +++++++++++++++++++ .../DD.Persistence.Client.csproj | 1 - DD.Persistence.Client/RefitClientFactory.cs | 5 ++--- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs diff --git a/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs b/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs new file mode 100644 index 0000000..6baa108 --- /dev/null +++ b/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs @@ -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; + +/// +/// Ошибка, которая выбрасывается в случае отсутствия необходимого свойства в appsettings.json +/// +public class AppSettingsPropertyNotFoundException : Exception +{ + /// + /// + /// + /// + public AppSettingsPropertyNotFoundException(string message) + : base(message) { } +} diff --git a/DD.Persistence.Client/DD.Persistence.Client.csproj b/DD.Persistence.Client/DD.Persistence.Client.csproj index 2395482..1d91345 100644 --- a/DD.Persistence.Client/DD.Persistence.Client.csproj +++ b/DD.Persistence.Client/DD.Persistence.Client.csproj @@ -52,7 +52,6 @@ - diff --git a/DD.Persistence.Client/RefitClientFactory.cs b/DD.Persistence.Client/RefitClientFactory.cs index 9cd0bef..28535f5 100644 --- a/DD.Persistence.Client/RefitClientFactory.cs +++ b/DD.Persistence.Client/RefitClientFactory.cs @@ -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 : IRefitClientFactory where T : IRefitClie var baseUrl = configuration.GetSection("ClientUrl").Get(); if (String.IsNullOrEmpty(baseUrl)) { - var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); + var exception = new AppSettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); logger.LogError(exception.Message); -- 2.45.2 From b894f61b66fee30eb7044c3c3de3db4b57381a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Tue, 4 Feb 2025 13:29:07 +0500 Subject: [PATCH 2/2] =?UTF-8?q?ClientUrl=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=B2=20Peristenc?= =?UTF-8?q?eClientUrl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DD.Persistence.App/appsettings.json | 2 +- DD.Persistence.Client/RefitClientFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DD.Persistence.App/appsettings.json b/DD.Persistence.App/appsettings.json index 7ad8c67..12b91e4 100644 --- a/DD.Persistence.App/appsettings.json +++ b/DD.Persistence.App/appsettings.json @@ -21,5 +21,5 @@ "grantType": "password", "http://schemas.xmlsoap.org/ws/2005/05/identity /claims/nameidentifier": "7d9f3574-6574-4ca3-845a-0276eb4aa8f6" }, - "ClientUrl": "http://localhost:5000/" + "PeristenceClientUrl": "http://localhost:5000/" } diff --git a/DD.Persistence.Client/RefitClientFactory.cs b/DD.Persistence.Client/RefitClientFactory.cs index 28535f5..7072944 100644 --- a/DD.Persistence.Client/RefitClientFactory.cs +++ b/DD.Persistence.Client/RefitClientFactory.cs @@ -22,7 +22,7 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie //this.client = factory.CreateClient(); this.client = client; - var baseUrl = configuration.GetSection("ClientUrl").Get(); + var baseUrl = configuration.GetSection("PeristenceClientUrl").Get(); if (String.IsNullOrEmpty(baseUrl)) { var exception = new AppSettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); -- 2.45.2