XmlSerializer vs DataContractSerializer

2019-04-12 07:29发布

问题:

I just realized that DataContractSerializer expects nodes in the alphabetical order or the specified order. Is there any way i could make it NOT do it?

TIA

回答1:

I don't think so. You may find the discussion on this question informative:

Ignore field order in DataContractSerializer



回答2:

I used IDispatchMessageInspector.AfterReceiveRequest to intercept the message and sort it alphabetically.