Mesen2/UI/Config/BaseConfig.cs
Sour d208fdc6a7 UI: Support for NativeAOT
Added Windows & Linux builds using AOT compilation
2024-06-05 20:23:31 +09:00

26 lines
571 B
C#

using Mesen.Utilities;
using ReactiveUI;
using System;
using System.Text.Json;
namespace Mesen.Config
{
public class BaseConfig<T> : ReactiveObject where T : class
{
public T Clone()
{
if(this is T obj) {
return JsonHelper.Clone<T>(obj);
} else {
throw new InvalidCastException();
}
}
public bool IsIdentical(T other)
{
string a = JsonSerializer.Serialize(this, this.GetType(), MesenSerializerContext.Default);
string b = JsonSerializer.Serialize(other, this.GetType(), MesenSerializerContext.Default);
return a == b;
}
}
}