I am designing a list-based app in C# WinForms where I want to store my data in an XML file (which will eventually get serialized into a database). I have a custom control that displays my list data based on my XML, but I’m having trouble determining the best structure to handle the data. I have a ListManager class that keeps track of an XMLDocument, and has methods like CreateList and AddListItem. Should I be using a local copy of the XML structure as what my UI Control reads from, or should I use the actual XML File itself? Is there something better than the XMLDocument that I should be storing as a member variable to keep hold of the data?
Also, how should I go about linking the controller with the UI control? In other words, how should my ListManager alert the ListControl when a new item was added? (Or should it not be doing the update notification at all, and instead the Main Form should do that?)
Thanks!
I would create a custom class to hold my data using strongly typed collections such as the generic collections System.Collections.Generic.List. Then, you can just serialize this class to and from XML on the client until you are ready to push the content into a database. Using serialization means you can work with plain old C# objects instead of trying to shoe-horn the XMLDocument class into your business object.
Take a look at this article for some details on how serialization works.