发送过WCF一个元组对象吗? [英] Sending a Tuple object over WCF?
问题描述
是 System.Tuple
通过WCF的数据契约序列化支持的类(即我可以通过元组
反对WCF调用和/或接收他们为部分或全部的结果)?
Is the System.Tuple
class supported by WCF's Data Contract Serializer (i.e., can I pass Tuple
objects to WCF calls and/or receive them as part or all of the result)?
我发现此页面,但不清晰,明确的,您可以发送和接收元组与WCF回答我所期待的。
I found this page, but not the clear, definitive "you can send and receive Tuples with WCF" answer I was hoping for.
我猜你可以,只要所有类型的范围内的 的的元组
本身是由数据协定序列化支持 - - 谁能给我提供一个更明确的答案?谢谢你。
I'm guessing that you can, as long as all of the types within the Tuple
itself are supported by the Data Contract Serializer -- can anyone provide me with a more definitive answer? Thanks.
推荐答案
在元组
类型都标有 SerializableAttribute
,因此,如果您存储中的类型是序列化的,他们应该能够通过WCF序列化为好。
The Tuple
types are marked with SerializableAttribute
, therefore, if the types you store within are serializable, they should be able to be serialized by WCF as well.
Check out: links of Tuple'1, Tuple'2, etc. It says:
[SerializableAttribute]
public class Tuple<T1> : IStructuralEquatable, IStructuralComparable, IComparable, ITuple
请注意,您链接文件包含以下行:
Note that the document you linked contains the following line:
未在部分信任的环境中支持的[Serializable接口] / ISerializable的编程模型。
The [Serializable] / ISerializable programming model is not supported in a partial trust environment.
所以,它可能不是因为它似乎容易。
So, it may not be as easy as it would seem.
(顺便说一句,在元组静态类也值得一试。)
(BTW, the Tuple static class is also worth checking out.)
这篇关于发送过WCF一个元组对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!