minor fixes

This commit is contained in:
Pilzinsel64
2025-04-25 10:30:38 +02:00
parent c232b856b9
commit 50796391f9

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
namespace Pilz.Configuration; namespace Pilz.Configuration;
@@ -17,7 +18,7 @@ public class SettingsValueOption<T> : ISettingsValueOptionValueAccessor where T
public SettingsValueOption(T value) public SettingsValueOption(T value)
{ {
this.value = DefaultValue = value; DefaultValue = value;
} }
public virtual T Value public virtual T Value
@@ -34,7 +35,13 @@ public class SettingsValueOption<T> : ISettingsValueOptionValueAccessor where T
object ISettingsValueOptionValueAccessor.ValueRaw object ISettingsValueOptionValueAccessor.ValueRaw
{ {
get => value; get => value;
set => this.value = (T?)(T)value; set
{
if (value is not null)
this.value = Convert.ChangeType(value, typeof(T)) as T?;
else
this.value = null;
}
} }
public virtual void Reset() public virtual void Reset()