C # Advanced XML serializer that does not require pollution of domain objects

Are there any open source projects for the XML serializer for C # that can serialize for the most part any object without having to pollute the objects of my domain with a lot of attributes? Will it also handle serializing collections built using generic generic classes? The bonus will be that it can handle serialization of an interface type property. Another bonus will be that it can serialize objects that have read-only properties (or, at least, with the internal access of the access recipient)

+3
source share
2 answers

Well, first define "advanced", that is, what exactly do you need, what XmlSerializerdoes not. From the point of view of POCO, it XmlSerializerhas an overloaded ctor that accepts all the attributes you will ever want to add so as not to add them to your object model - but this still requires a public constructor without parameters and only works in public read / write fields / properties. And if you use this approach, you should cache / reuse the serializer.

, , " " - DTO. , DTO (-), ( ctor/properties/etc).

, ctor/properties DataContractSerializer , , xml.

+5
  • System.Xml.dll InternalsVisibleToAttribute. , / . .ctors.
  • IXmlSerializable , (, , ).
  • XML , XmlAttributeOverrides.

XmlSerializer , , , , .

0

Source: https://habr.com/ru/post/1721348/


All Articles