Files
VigilModManager/ModRegistry/Settings/SettingsElement.cs
Exil Productions 74e53205f4 Initial Code
2025-11-11 03:10:52 +01:00

31 lines
766 B
C#

using System;
using System.Collections.Generic;
using System.Text;
using VMM.ModRegistry.Settings;
namespace VMM.ModRegistry.Settings
{
public abstract class SettingsElement<T> : ISettingsElement
{
public string Name { get; set; }
public T Value { get; set; }
public Action<T> OnChanged { get; set; }
public object GetValue() => Value;
public void SetValue(object value)
{
if (value is T typedValue)
{
Value = typedValue;
OnChanged?.Invoke(typedValue);
}
else
{
throw new InvalidCastException($"Invalid value type. Expected {typeof(T)}, got {value?.GetType()}");
}
}
}
}