Good afternoon everyone
I am an independent game developer who in the past worked mainly with XNA and, on the other hand, commercial tools. However, the reach of XNA is quite limited, and I am creating a cross-platform level of abstraction to define multiple platforms.
To shorten the long story, I needed XML serialization, which is more widely available than [Serializable], and I pointed to data contracts. I have done a lot of research, but I can not find any good information about the elements of the system related to inheritance and overrides.
The essence of my question ...
[DataContract] public class Node { private string name; public string Name { get { return name; } set { name = value; } } public virtual float Rotation { get { return 0f; } set { } } } [DataContract] public class FancyNode : Node { private float rotation; public override float Rotation { get { return rotation; } set { rotation = value; } } }
If I serialize "FancyNode", will the "Rotation" be correctly serialized and will the "Name" be serialized?
Follow-up question: I wanted to ask earlier, but I could not remember at that time. How does the serializer handler override the properties of [IgnoreDataMember]? For example...
[DataContract] public class Simple { [IgnoreDataMember] public virtual string Value { get { return ""; } set { } } } [DataContract] public class Complex : Simple { private string value; public override string Value { get { return value; } set { this.value = value; } } }
Will the "Value" in the "Complex" be serialized? Some answers suggest that if the [DataMember] tags are not used, all properties will be serialized. If so, does the [IgnoreDataMember] attribute of the base class have any bearing?
Nathan runge
source share