XmlSerializer, “Specified” suffix and IReflect

I've discovered that if a serializable Field/Property has a corresponding field of type Boolean having as a name the Field/Property name with "Specified" suffix, the XmlSerializer conditionally exclude that Field/Property from the serialization process. Nice!

So, I want to avoid the definition of those fields, and add them dynamically, at runtime...

Reading this, I found an interesting interface IReflect, which I can use to "emulate" dynamic fields which are used by the XmlSerializer instances to exclude certain fields.

Would this work?

7
задан Community 23 May 2017 в 12:18
поделиться