MapWindow / MapWindow5

MW5 is a desktop GIS which is extendable using the plug-in architecture. It is using the MapWinGIS mapping control and is created from scratch in 2015 using new technologies like MEF and Dependency Injection making it small in size, robust and fast.
290 stars 100 forks source link

Plugin Serialization #7

Closed dhuantes closed 6 years ago

dhuantes commented 7 years ago

My previous MapWindow4 plugin implement overrides for ProjectLoading and ProjectSaving methods to add plugin specific state information that I wanted to save/serialize to the project file. Looking through MapWindow5 I'm not finding an obvious replacement. Unfortunately I'm more of a C++ guy than a C# guy but it looks like MW5 is leveraging the DataContractSerializer (wrapped by DataContractSerializer) to serialize XmlProject which has DataMembers that reference just about everything else. The only Plugin Serialization that is done though appears to via the Plugins property of tthe XmlProject. Unfortunately XmlPlugin is only one that doesn't use the DataContract and DataMember attributes..... How is a plugin developer supposed to serialize to the project file? Thought I'd ask just in case someone already knows this answer. I'll continue digging. Thanks!

pmeems commented 7 years ago

I spoke with Sergey about it and this is reply:

It seems that the only way to save plugin settings right now is via AppConfig.cs class. It has settings for several plugins. It certainly not practical for custom plugins. I would suggest to serialize / deserialize their settings in BasePlugin.Initialize / BasePlugin.Terminate events. Also it seems to me that BasePlugin.Teminate event is not fired on closing the application. It should be called. If some plugin settings should be saved to the project file, I would suggest to add XmlPlugin.State property (string). I guess it will also require some tweaks to project / plugin events (I don't see ProjectOpened event in BasePlugin class for example).

So at the moment it is not possible to easily save your custom plug-in settings. Feel free to make the changes Sergey suggests and send me the patch

dhuantes commented 7 years ago

Unfortunately I've been buried in other projects for most of 2017 but expect to have time later this summer to work my MapWindow 5 plugin project. I had previously discussed using PostGreSQL for persisting project settings with the end users. Has that been flushed out/demonstrated by any plugins in MapWindow5? Additionally it would be nice if the plugin developer's were provided an interface that allowed them to select either a DB or project file to persist their changes without significant differences. So I will look at project file persistence but would like to do so knowing the way I would do the same with a DB. Thanks!