Suppose I have some data in a file in XML, JSON or YAML formats. All documents have the same logical structure. In simple case: all files have in root element attribute Version.
I suppose to create class that can read and write data from/to file this formats:
enum FileFormat {JSON, XML, YAML};
class File {
FileFormat FileFormat { get; } // We cannot change file format
int Version { get; set; } // We can read/change root attribute Version
Load(string fileName, FileFormat fileFormat); // We can load from JSON/XML/YAML formats
Save (string fileName); // We can save changed in the same format as we read
}
Which design pattern should I use in Load/Save to choose the right serializer/deserializer?
No comments:
Post a Comment