开发者

Serializing both to local and SOAP with private members c#

Can someone please point me in the right direction? I am trying to serialize some classes for dual use: 1) to save data locally in XML format and 2) to send the classes to a web service using SOAP.

There are some (private) members in the class that I want to save locally, but I do not want them over the wire. Is 开发者_如何学Gothere a way to do this without having 2 near copies of the same class (one with the private members, and the other without)?

Edit: The point of this post is not to determine which is the best way for me to serialize private members, but to figure out a way to serialize my data locally so I can save the ALL my class information in XML on my local box, and yet still be able to serialize a defined subset of those members so I can pass them through SOAP to a web service.

Hope that makes sense!


I'd recommend using the DataContractSerializer that's what WCF uses for SOAP purposes, and with the DataContract you can decorate private members as participating in serialization

Here's a good link for DataContract usage http://msdn.microsoft.com/en-us/library/ms733127.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜