mardi 6 juillet 2021

How can I cache reflective information about the structure of my classes?

I have a set of auto-generated C# classes courtesy of XmlSchemaClassGenerator, and I would like to open up an REST API to parse XMLs and query the contents of the parsed XML.

Given that these classes have been auto-generated from schemas, the structure of the classes are well-known, and might be cached, so I don't need to perform something like object.GetType().GetField("field1").GetType().GetField("field2")....GetField("fieldn"), and instead look up the the final field in a hash-table, and expand it to a direct call to object.field1.field2....fieldn.

How might I achieve this?





Aucun commentaire:

Enregistrer un commentaire