freetubesync/FreeTubeSync/Model/Setting.cs
Mario Steele e1ad30da0c Updated Setting
Added Update() method to model.
2025-07-21 17:08:43 -05:00

30 lines
No EOL
794 B
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
namespace FreeTubeSync.Model;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class Setting
{
[Key]
#pragma warning disable CS8618
public string _id { get; set; } = string.Empty;
public string? ValueJson { get; set; }
#pragma warning restore CS8618
[NotMapped]
public object Value
{
#pragma warning disable CS8603
get => string.IsNullOrEmpty(ValueJson) ? null : JsonSerializer.Deserialize<object>(ValueJson);
#pragma warning restore CS8603
set => ValueJson = JsonSerializer.Serialize(value);
}
public void Update(Setting other)
{
Value = other.Value;
}
}