c# - XML Serialization of the default values of optional attributes -


I have classes using xsd.exe, and I'm trying to sort them. However, one attribute is not being included in the resulting XML, here's a part of the schema where the problem is.

  & lt; Xsd: element name = "widget" & gt; & Lt; XSD: complexType & gt; / * Sequence for brevity * / & lt; Xsd: use attribute name = "version" type = "version" = "optional" default = "1.1" /> & Lt; / XSD: complexType & gt; & Lt; / XSD: element & gt; & Lt; Xsd: Simple Type Name = "Version" & gt; & Lt; Xsd: ban base = "xsd: string" & gt; & Lt; Xsd: calculation value = "1.0" /> & Lt; Xsd: calculation value = "1.1" /> & Lt; / XSD: Ban & gt; & Lt; / XSD: simpleType & gt; XSD.XE has created a property called "version" on a "widget" class and has created another property named "Version Spissuit", but it does not occur when I Serialize the truth:    [XmlAttributeAttribute] [DefaultWelcomeActivate (version.Version_1_1)] {Receive Public Version Version; Set; } [Serialization.XmlIgnoreAttribute] Specified the Public Bund version {get; Set; }  

and this is the calculation it is based on:

  /// & lt; Remark / & gt; [Generated Code Contribution ("XSD", "2.0.50727.3038") [Serialable] Public Enum version ([XmlEnumAttribute ("1.0")] version_1_0, [XmlEnumAttribute ("1.1")] Version_1_1,}  

code snippet as requested

  widget widget = new widget (); Widgets Version = version Version_1_1; Widgets Version clear = true; XmlSerializer serializer = New XmlSerializer (widget.GetType ()); Serializer.Serialize (/ * Memory Stream Object / /, Widget);  

Do anyone have any idea why the serialization refuses to present this feature? Due to this you specified the default value as "1.1"

Property will be equal to its basic value when serial element / attribute will not be created.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -