我想将对象转换为字符串和副Versa进程。 情况是,我们正在使用WCF DataService的WebGet方法。 这不支持将对象作为返回类型。 因此我需要将对象转换为服务器端的字符串,并将字符串转换为客户端的对象。 我不想添加[Serializable]属性,因为我可能转换的对象是第三方类,我无法序列化。 什么是最好的解决方案。
I would like to convert the object to string and Vice Versa process. The situation is, we are using WCF DataService's WebGet method. This doesn't support object as return type. for this reason i need to convert the object to string in server side and string to object at client side. I doesn't want to add [Serializable] attribute, because the object i may convert is third party class and i can't serialize. what could be the best solution.
最满意答案
我认为将第三方类转换为一些自定义xml会更好。 从字符串重新创建对象可能非常困难。
您可以在不使用[Serializable]属性的情况下将类序列化为xml:
如何使用Visual C#将对象序列化为XML
I think converting the third party class into some custom xml would be better. It might be very difficult to recreate the object from a string.
You can serialze a class to xml without using the [Serializable] attribute:
How to serialize an object to XML by using Visual C#
更多推荐
发布评论