It is certainly possible. I want to illustrate a solution using XElement , which, by the way, I really liked. You do not need to use the XmlSerializer or DataContractSerializer or any class or property annotations, such as [DataContract] or [Serializable] , if you do not want to. In addition, the example below shows how you can exchange a private set for an internal set in my example, by the way:
using System; using System.Linq; using System.Xml.Linq; namespace SerializationTesting { class Person {
The result of all equality checks in the console application above will be true , as expected. This does not suffer from troubles, such as the need to track encodings or the way of analyzing data, because it does all of this for you, and it does not limit your class to public setters, as XmlSerializer does.
Alexandru Dec 10 '14 at 22:43 2014-12-10 22:43
source share