2024-07-04 23:45:33 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Common.Services;
|
|
|
|
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.Json.Serialization;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
2024-07-04 23:54:17 +03:00
|
|
|
|
namespace Mirea.Api.Endpoint.Common.Settings;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
2024-07-04 23:54:17 +03:00
|
|
|
|
public class GeneralConfig : ISaveSettings
|
2024-05-28 06:38:24 +03:00
|
|
|
|
{
|
2024-07-04 23:45:33 +03:00
|
|
|
|
[JsonIgnore] private const string FileName = "Settings.json";
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public static string FilePath => PathBuilder.Combine(FileName);
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
|
|
|
|
public DbSettings? DbSettings { get; set; }
|
|
|
|
|
public CacheSettings? CacheSettings { get; set; }
|
|
|
|
|
public ScheduleSettings? ScheduleSettings { get; set; }
|
|
|
|
|
public EmailSettings? EmailSettings { get; set; }
|
|
|
|
|
public LogSettings? LogSettings { get; set; }
|
2024-07-04 23:46:43 +03:00
|
|
|
|
public string? SecretForwardToken { get; set; }
|
2024-07-04 23:45:33 +03:00
|
|
|
|
|
|
|
|
|
public void SaveSetting()
|
|
|
|
|
{
|
|
|
|
|
File.WriteAllText(
|
|
|
|
|
FilePath,
|
|
|
|
|
JsonSerializer.Serialize(this, new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
WriteIndented = true
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-28 06:38:24 +03:00
|
|
|
|
}
|