Some background:
We need to sort some unit sections, In the first version, as the following:
[XmlType ("FooElement")] Public square Fu {[XmlText] Public string text {get; Set; }}
The serial XML string should be:
But we need to make text properties read-only, so we change the Foo class to implement the IXmlSerializable interface as the following:
[serializable] Public square fu: IXmlSerializable {public Foo () {} public Foo (string text) {text = text; } Public string text {get; Private set; } Public XmlSchema GetSchema () {return tap; } Public Zero ReadXml (XmlReader Reader) {text = reader.Value; } Public Zero WriteXml (XmlWriter Writer) {writer.WriteValue (text); }}
The subsequent XML string was also changed as the following:
& lt ;? XML version = "1.0" encoding = "GB2312"? & Gt; & Lt; Foo & gt; Foo & lt; / Foo & gt;
What "
"from" lift; FooElement & gt; Foo & lt; / FooElement & gt;
"?
I think, should play well with IXmlSerializable.
Comments
Post a Comment