C# XML serialization attributes
Where | Attribute | Function |
class | XmlRoot |
name a root element |
field, property, parameter, or return value | XmlAttribute |
serialized as an XML attribute |
field, property, parameter, or return value | XmlElement |
serialized as an XML element |
field, property, parameter, or return value of type XmlAttribute[] |
XmlAnyAttribute |
collects all unknown attributes |
field, property, parameter, or return value of type XmlElement[] |
XmlAnyElement |
collects all unknown elements |
field, property | XmlIgnore |
not part of serialization |
field, property, parameter, or return value that returns an array of complex objects | XmlArray |
|
field, property, parameter, or return value that returns an array of complex objects | XmlArrayItem |
|
field, property, parameter, or return value | XmlChoiceIdentifier |
|
field that is an enumeration identifier | XmlEnum |
serialization of an enumeration member |
derived class declarations, and return values of public methods (WSDL) | XmlInclude |
should be included when generating schemas |
properties and fields | XmlText |
serialized as XML text |
class declarations | XmlType |
name and namespace of the XML type |
Limitations of XML serialization
- Does not handle mixed mode (all mixed items are gathered in one XmlText)
- Serialization of interfaces (there is currently no way to specify an underlying type for deserialization)
- Due to dynamic code generation that accesses the serialized types from outside all the members and classes to be serialized MUST be public.
link: http://www.color-of-code.de/index.php/cheat-sheets/programming/c-serialization-attributes
This comment has been removed by a blog administrator.
ReplyDelete