Mesen2/UI/Config/BaseConfig.cs
2023-01-25 16:03:56 -05:00

26 lines
547 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(), JsonHelper.Options);
string b = JsonSerializer.Serialize(other, this.GetType(), JsonHelper.Options);
return a == b;
}
}
}