XmlSerializer vs DataContractSerializer: Serialization in Wcf

这篇文讲得不错,可惜居然要翻墙。

摘录:

The XmlSerializer has been in .Net since version 1.0 and has served us well for everything from Remoting, Web Services, serializing to a file, etc. However in .Net 3.0 the DataContractSerializer came along.? And all of a sudden a lot of guidance suggests that we should use it over the old tried and true XmlSerializer. Wcf even uses this as the default mechanism for serialization.? The question is, “Is it really better?”.? The verdict is yes, and no.? Like most things it depends on your implementation and what you need.? For Wcf, you should prefer to use the DataContractSerializer.? If you need full control over how the xml looks though, you should go back to the XmlSerializer.

Lets look at the both of these in detail and leave it up to you to decide which is best for your implementation.? Here are a few of the advantages and disadvantages of each of them:

。。。。。。。。

发表回复