fix: invalid cast in importing proxy_switch

This commit is contained in:
rladenson 2024-12-06 12:57:17 -07:00
parent 1c0925a178
commit 0b283f5631

View file

@ -1,3 +1,4 @@
using System.Diagnostics;
using Newtonsoft.Json.Linq;
using NodaTime;
@ -150,7 +151,12 @@ public class SystemConfigPatch: PatchObject
patch.HidDisplayCaps = o.Value<bool>("hid_display_caps");
if (o.ContainsKey("proxy_switch"))
patch.ProxySwitch = o.Value<SystemConfig.ProxySwitchAction>("proxy_switch");
patch.ProxySwitch = o.Value<string>("proxy_switch") switch
{
"new" => SystemConfig.ProxySwitchAction.New,
"add" => SystemConfig.ProxySwitchAction.Add,
_ => SystemConfig.ProxySwitchAction.Off,
};
if (o.ContainsKey("name_format"))
patch.NameFormat = o.Value<string>("name_format");