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