diff --git a/Serialization/NotificationConverter.cs b/Serialization/NotificationConverter.cs index 00e6d56..8234a50 100644 --- a/Serialization/NotificationConverter.cs +++ b/Serialization/NotificationConverter.cs @@ -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;