xmlignore

Using XmlAttributeOverrides on Nested Properties

旧巷老猫 提交于 2019-12-09 19:41:59
问题 I am trying to use XmlAttributeOverrides to control which class properties appear in the xml after the class has been serialized. It works on properties that are on the "root" class but not on nested properties. Here is a simple example to illustrate what I'm trying to accomplish. My class hierarchy is as follows: public class Main { public string Name { get; set; } public Location Address { get; set; } } public class Location { public string StreetAddress { get; set; } public Contact

Using XmlAttributeOverrides on Nested Properties

旧巷老猫 提交于 2019-12-04 15:53:32
I am trying to use XmlAttributeOverrides to control which class properties appear in the xml after the class has been serialized. It works on properties that are on the "root" class but not on nested properties. Here is a simple example to illustrate what I'm trying to accomplish. My class hierarchy is as follows: public class Main { public string Name { get; set; } public Location Address { get; set; } } public class Location { public string StreetAddress { get; set; } public Contact ContactInfo{ get; set; } } public class Contact { public string PhoneNumber { get; set; } public string

XmlIgnoreAttribute, only used during serialization, not during deserialization?

拜拜、爱过 提交于 2019-12-04 03:17:48
问题 Am I right in understanding the .NET XmlIgnoreAttribute, which says: Instructs the Serialize method of the XmlSerializer not to serialize the public field or public read/write property value. that: The property will be deserialized, if present in the XML file? The property will not be serialized to a new XML file? The reason I'm asking is that I have replaced a property in the file with a new one with more options. The old property was a simple boolean property, and the new one is an enum. I

C# Attribute XmlIgnore and XamlWriter class - XmlIgnore not working

不想你离开。 提交于 2019-11-29 10:29:52
I have a class, containing a property Brush MyBrush marked as [XmlIgnore] . Nevertheless it is serialized in the stream causing trouble when trying to read via XamlReader . I did some tests, e.g. when changing the visibility of the Property (to internal) it is gone in the stream. Unfortunately I cannot do this in my particular scenario. Did anybody have the same issue and? Do you see any way to work around this? Remark: C# 4.0 as far I can tell This is a method from my Unit Test where I do test the XamlSerialization : // buffer to a StringBuilder StringBuilder sb = new StringBuilder();

C# Attribute XmlIgnore and XamlWriter class - XmlIgnore not working

ぐ巨炮叔叔 提交于 2019-11-28 03:50:41
问题 I have a class, containing a property Brush MyBrush marked as [XmlIgnore] . Nevertheless it is serialized in the stream causing trouble when trying to read via XamlReader . I did some tests, e.g. when changing the visibility of the Property (to internal) it is gone in the stream. Unfortunately I cannot do this in my particular scenario. Did anybody have the same issue and? Do you see any way to work around this? Remark: C# 4.0 as far I can tell This is a method from my Unit Test where I do