20240224
This commit is contained in:
23
anbs_cpfn/Classes/AppSettings.cs
Normal file
23
anbs_cpfn/Classes/AppSettings.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace anbs_cp.ForNet.Classes;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-поддержки для доступа к файлу "appsettings.json" в любом месте сайта классах.
|
||||
/// Взято с: https://stackoverflow.com/a/69111159/16469671
|
||||
/// </summary>
|
||||
public static class AppSettings
|
||||
{
|
||||
// ReSharper disable once NotAccessedField.Global
|
||||
// ReSharper disable once NotNullOrRequiredMemberIsNotInitialized
|
||||
public static IConfiguration? Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация настроек. Она проводится в файле Program.cs.
|
||||
/// </summary>
|
||||
/// <param name="configuration">Параметры из "appsettings.json"</param>
|
||||
public static void Initialize (IConfiguration configuration)
|
||||
{
|
||||
Config = configuration;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user