I'm working on a small (.Net 5 wpf) app, which loads and saves its state from/into json files (using Newtonsoft library). I save it with $type and $id fields.
Now I have added a plugin system, where I load assemblies from a folder and create objects from them into my app state (say, my model/viewmodel). When I'm saving my model, everything runs fine. I checked the $type, and it's the real name.
My issue is: how to load it back (without writing custom parsing code) ? My plugin types are stored in a List in my plugin service, and newtonsoft has no knowledge of them. So, I have 2 questions:
- how do I tell newtonsoft lib to take my types into account ?
- and/or how do I tell the environment running my app (framework ? app domain ?) to meet my types, and consider them as known for the rest of the time my app is launched ?
I have no useful code to show cause everything happens in a DeserializeObject() method. Thank you for any help.
Aucun commentaire:
Enregistrer un commentaire