XmlSerializer, “Specified” suffix and IReflect

后端 未结 3 1841
清酒与你
清酒与你 2021-01-02 15:06

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 \"S

3条回答
  •  旧时难觅i
    2021-01-02 15:29

    If you want to take control of your xml serialization then you have two options. The first (which might not be appropriate here) it to use the attributes in the System.Xml.Serialization namespace to exclude properties. If you really need to do determine what gets serialized at runtime this might not be the best course of action.

    See Attributes That Control XML Serialization

    The other way to do this is to implement the IXmlSerializable interface on your class and implement the ReadXml and WriteXml methods. This allows you to take control of exactly how your xml looks. See this question for additional info:

    custom xml serialization

    However, as mentioned here Mixing custom and basic serialization? once you implement IXmlSerializable you are responsible for all the serialization logic for your type.

提交回复
热议问题