本文介绍了DataContractSerializer的是一个选择的序列化。如何使它选择退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一些类有大量的属性。我希望能够连载他们 WCF

I inherited some classes with a large number of attributes. I want to be able to serialize them for WCF.

由于的DataContractSerializer 是一个选择序列化,我将需要装饰的所有属性与数据成员属性,这在我看来有点麻烦。难道我周围有任何其他方式,这样我就不用加数据成员所有属性?

As DataContractSerializer is an opt-in serializer, I will need to decorate all the properties with DataMember attribute, which seems to me a little cumbersome. Don't I have any other way around so that I don't have to add DataMember to all the properties?

请注意,我的大部分属性需要被序列化。

Please note, most of my properties need to be serialized.

推荐答案

DOTNET 4.0 以上,

您可以避开 [DataContract] 属性,以使所有的公开数据成员序列化

You can avoid the [DataContract] attribute to make all the public datamembers serializable.

这篇关于DataContractSerializer的是一个选择的序列化。如何使它选择退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 02:50