From ed8253e99bd99b4a20ecc3e88005628dbcb249d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=91=D0=B0=D0=B1=D0=B0=D0=B5=D0=B2?= Date: Sat, 24 Feb 2024 14:04:34 +0300 Subject: [PATCH] 20240224 --- anbs_cpfn/Classes/AppSettings.cs | 23 ++++++++++++++++++++++ anbs_cpfn/anbs_cpfn.csproj | 8 ++++---- anbsoftware.componentspack.sln.DotSettings | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 anbs_cpfn/Classes/AppSettings.cs diff --git a/anbs_cpfn/Classes/AppSettings.cs b/anbs_cpfn/Classes/AppSettings.cs new file mode 100644 index 0000000..beeac27 --- /dev/null +++ b/anbs_cpfn/Classes/AppSettings.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; + +namespace anbs_cp.ForNet.Classes; + +/// +/// Класс-поддержки для доступа к файлу "appsettings.json" в любом месте сайта классах. +/// Взято с: https://stackoverflow.com/a/69111159/16469671 +/// +public static class AppSettings +{ + // ReSharper disable once NotAccessedField.Global + // ReSharper disable once NotNullOrRequiredMemberIsNotInitialized + public static IConfiguration? Config { get; private set; } + + /// + /// Инициализация настроек. Она проводится в файле Program.cs. + /// + /// Параметры из "appsettings.json" + public static void Initialize (IConfiguration configuration) + { + Config = configuration; + } +} \ No newline at end of file diff --git a/anbs_cpfn/anbs_cpfn.csproj b/anbs_cpfn/anbs_cpfn.csproj index ffbbe4d..0050b6a 100644 --- a/anbs_cpfn/anbs_cpfn.csproj +++ b/anbs_cpfn/anbs_cpfn.csproj @@ -6,7 +6,7 @@ enable True ANBSoftware.ComponentsPackForNet - 2024.2.6.0 + 2024.2.24.0 Александр Бабаев Набор компонентов ANB Software для ASP.NET Core Библиотека полезных методов языка C# для ASP.NET Core @@ -20,12 +20,12 @@ - - + + - + diff --git a/anbsoftware.componentspack.sln.DotSettings b/anbsoftware.componentspack.sln.DotSettings index f318569..37099bd 100644 --- a/anbsoftware.componentspack.sln.DotSettings +++ b/anbsoftware.componentspack.sln.DotSettings @@ -8,6 +8,7 @@ True True True + True True True True