Add PropertyChanged detection for Dictionary type settings

This commit is contained in:
Michael Bucari-Tovo 2023-01-06 19:46:55 -07:00
parent 1f7000c2c9
commit 5c73beff4b
11 changed files with 211 additions and 179 deletions

View file

@ -49,8 +49,10 @@ namespace FileManager
public T GetNonString<T>(string propertyName)
{
var obj = GetObject(propertyName);
if (obj is null) return default;
if (obj is null) return default;
if (obj.GetType().IsAssignableTo(typeof(T))) return (T)obj;
if (obj is JObject jObject) return jObject.ToObject<T>();
if (obj is JValue jValue)
{
if (jValue.Type == JTokenType.String && typeof(T).IsAssignableTo(typeof(Enum)))
@ -62,8 +64,7 @@ namespace FileManager
}
return jValue.Value<T>();
}
if (obj is JObject jObject) return jObject.ToObject<T>();
return (T)obj;
throw new InvalidCastException($"{obj.GetType()} is not convertible to {typeof(T)}");
}
public object GetObject(string propertyName)