Design Pattern for XML Based Project Files in C #

I am developing a C # application where most of the code base is in C # class libraries. I want the application to support the saving and loading of XML-based project files and the ability to determine if there have been any changes since the last save.

My current design idea is:

  • Each class that needs to save settings implements IXmlSerializable.

  • The application maintains a common list of IXmlSerializable settings objects and calls ReadXml and WriteXml to save / load the project files.

  • Each class in which settings are stored also supports the Modified flag.

  • An application can check if a project has been modified by listing the general list of IXmlSerializable objects and checking the Modified flag for each. It can also clear the Modified flag every time it is saved.

Is this a good design? Are there any better ones? Perhaps I also need to get my own interface from IXmlSerializable to add the Modified flag?

thanks Andy

+3
source share
1 answer

I think the concept you go sounds like. I have only one concern, and maybe I read a lot in your wording.

, , WriteXml, . , , , , . XmlSerialization - , .

, , , , , , , . IXmlSerializable , - , .

+2

Source: https://habr.com/ru/post/1764314/


All Articles