←back to thread

294 points NotPractical | 1 comments | | HN request time: 0.199s | source
Show context
Spivak ◴[] No.41855620[source]
Any C# devs wanna explain the XML thing? To me having a separate class to deserialize each kind of XML document to its respective object seems nice and the "right" way to use XML. The class just becomes the config file. Generic loaders but poking at the tree is super brittle. Does C# come with magic to do this better?

Because if you have to invent the config file then isn't that creating a DSL and we're back to over engineering?

replies(3): >>41855737 #>>41855790 #>>41858899 #
1. marcosdumay ◴[] No.41858899[source]
> To me having a separate class to deserialize each kind of XML document to its respective object

You mean a separate function? Or a separated method in some class? (Given that C# can't do top level functions...)

Or else, you may want a type parametrized function that uses reflection to populate an object of any class you want. That would depend on how many different kinds of file you have, but the C# standard library has this function so you just use it.