I have a situation whereby I'm using a library that's been generated to provide an XML interface in C# based upon an
XSD file run through
The XML is structured as so.
-Results -ModelA -ModelB -ModelC -ModelD
When I'm actually working with this XML (which is mapped into internal memory objects thanks to the library) I have a lot of code that applies to all models. For example I may know that I can look for a field called
FinalResult in all four models.
If I had control over the classes that represent the models, I could refactor it so it would make more sense but the code that is generated treats these four models as separate entities, and the parent is only a parent in the sense that it has variables that point to its "children", not in an OOP sense.
So far as I can tell, this means I could use something like the
dynamic keyword in C# and avoid code duplication, or rewrite the code multiple times to have type safety, being forced to do so by the fact I don't have control over the external library.