I have a work-space object containing a list of target objects with their properties.
This is very simple to configure using Spring.Net. But the thing is that the target objects may be changed by the user (on the GUI): some can be added, removed and their properties may change.
I need to serialize the new work-space configuration on the fly to have it persistent when my app goes down.
Is there’s any automatic way to do that using Spring.Net, without having to deal with XML serialization? Or, is there’s a way to simplify the XML serialization in this case?
Is it logical to use Spring.Net in this case at all?
Thanks!
I have a work-space object containing a list of target objects with their properties.
Share
You should not use your dependency configuration as a means of persistent storage; it wasn’t built for that purpose. Think of the dependency configuration as a static configuration that you ship with your application.
If users of your application can change an object, then this generally isn’t an object you should configure using a dependency injection framework. You should consider saving and retrieving those objects using a database, a file (xml, plain text) or some other persistent store.
Consider injecting an object (let’s call it
TargetManager) on yourWorkSpacethat manages theTargetobjects. TheTargetManagercan access the persistent store and theWorkSpacewouldn’t know how theTargetManagerworks; only that it’ll give himTargets.So for the static configuration part of your application you can definitely use Spring.NET, but for the saving and retrieving of targets you shouldn’t use Spring.NET dependency injection features.
Xml serialization can be very simple in .net, but that really depends on the type of object you want to serialize. We’d need some more details on the objects you want to persist to help out there.