Add PropertyChanged detection for Dictionary type settings
This commit is contained in:
parent
1f7000c2c9
commit
5c73beff4b
11 changed files with 211 additions and 179 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue