Reinventing the wheel T_T
ref = CXuesong/XSerializer/
Pull is welcomed T_T if you’d like to
Recently I’ve been considering the following problems:
When serializing using `XmlSerializer` to get more control on what the XML should look like,
- How to serialize members with type `Nullable<T>`, persisting it as XML attribute (rather than element)?
- How to serialize references, avoiding it persisted as multiple identical copies of one object?
- How to achieve the these two things above, without introducting public auxiliary properties?
(e.g. for case 1, an auxiliary property can be introduced to do the conversions between `Nullable<T>` and `string`, the latter of which can be persisted as XML attribute.)
It seems that case 2 can be solved using `DataContractSeriallizer`. However, `DataContractSeriallizer` generates Id by itself, and represent Id and its references with `z:Id` and`z:Ref`. As I’ve mentioned in previously (在 XmlSerializer 与 DataContractSerializer 之间抉择), `DataContractSeriallizer` is rather rigid when you want to control the appearance of XML tree it generates.
Then, how to solve these problems?
Maybe, I’ll reinvent the wheel.