I am storing a serialized object as json (or perhaps xml in the future) in a database. At some later point this object will be pulled and derserialized. The base class is HighChart but there are several derived types as well such as HighChart.ColumnBarChart. The type of the chart is stored in the JSON. The problem is I cant figure out how I'm going to dynamically select the class to deserialize as.
My solution needs to provide a way to automatically take into account future derived types (I'm going to be expanding the number of chart types and do not want to program something new for every chart type).
I know that I could store the type to a seperate DB field - but again I would have to use a switch statement in my Deserialize method for every type. I could also parse the json string and discover the chart type, but again - I would have to use a switch statement for every possible type.
Thanks for your thoughts!