MireaBackend/Endpoint/Configuration/Model/GeneralConfig.cs

34 lines
1.0 KiB
C#
Raw Normal View History

2024-10-07 02:13:35 +03:00
using Mirea.Api.Endpoint.Common.Interfaces;
using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Settings;
2024-07-04 23:45:33 +03:00
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
2024-10-07 02:13:35 +03:00
namespace Mirea.Api.Endpoint.Configuration.Model;
2024-07-04 23:54:17 +03:00
public class GeneralConfig : ISaveSettings
{
2024-07-04 23:45:33 +03:00
[JsonIgnore] private const string FileName = "Settings.json";
[JsonIgnore]
public static string FilePath => PathBuilder.Combine(FileName);
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; }
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
})
);
}
}