简体   繁体   中英

Find number of serialized objects

My issue is trying to determine a number of objects created, the objects being serialized from an XML document. The XML document should be set up for simplicity, so any developer can add an additional object and need no further modification to the code. However each of these objects need to be handled/updated seperately, and specifically, some of the objects are of different sub-classes, which need to be handled differently. So what would be my simplest course of action, allowing other to add objects via the XML, but still ensuring the proper logic happenes for each?

This is totally a bad idea, but if you want something constructive...

Model your XML document objects and include some kind of known syntax for you to specify Lambda expressions in it. So if you enter a

 <BinaryExpresion>
     <NodeType>Add</NodeType>
     <Left>3</Left>
     <Right>4</Right>
 </BinaryExpression>

Then when you read and compile the expression, you could run that code against the data if the XML object and do something (in this case, executing 3 + 4)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM