30 lines
No EOL
838 B
C#
30 lines
No EOL
838 B
C#
using System.Text.Json;
|
|
using blazingconsole.Types;
|
|
using Microsoft.FluentUI.AspNetCore.Components;
|
|
|
|
namespace blazingconsole.Services
|
|
{
|
|
public class SettingsService
|
|
{
|
|
public event Action? OnSettingsChanged;
|
|
private SiteSettings RealSettings { get; set; } = new SiteSettings();
|
|
public SiteSettings Settings {
|
|
get => RealSettings.Clone();
|
|
set {
|
|
RealSettings = value.Clone();
|
|
OnSettingsChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public string Serialize() {
|
|
return JsonSerializer.Serialize(Settings);
|
|
}
|
|
|
|
public void Deserialize(string json) {
|
|
var result = JsonSerializer.Deserialize<SiteSettings>(json);
|
|
if (result != null) {
|
|
Settings = result;
|
|
}
|
|
}
|
|
}
|
|
} |