lucidiot/HabitSharp
lucidiot
/
HabitSharp
Archived
1
0
Fork 0

Fix notification parsing

This commit is contained in:
Lucidiot 2018-11-10 18:19:06 +01:00
parent 4e28893225
commit 879242a69d
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
1 changed files with 1 additions and 4 deletions

View File

@ -35,10 +35,7 @@ public class NotificationConverter : JsonConverter
{
JObject jo = JObject.Load(reader);
Type noteClass = FindNotificationSubclass((string)jo["type"]);
// Dirty hack to use a Type variable as a type in a generic method
// TODO: There probably is a nicer way to do this.
var method = typeof(JObject).GetMethod("ToObject").MakeGenericMethod(new Type[] { noteClass });
return method.Invoke(jo, new object[] { serializer });
return Convert.ChangeType(jo.ToObject(noteClass), noteClass);
}
public override bool CanWrite => false;