【发布时间】:2013-05-21 11:50:11
【问题描述】:
我正在寻找如何使用 protobuf-net 序列化和套接字连接在两台机器之间传输集合的完整示例。我成功找到的只是代码的单独部分,没有人不能向像我这样的菜鸟解释如何组合所有这些东西。在 .proto 文件之后:
using System;
using ProtoBuf;
namespace Proto.Transaction
{
[Serializable]
[ProtoContract]
public class Transaction
{
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public int AgentID { get; set; }
[ProtoMember(3)]
public string TransactionName { get; set; }
[ProtoMember(4)]
public string ScriptName { get; set; }
[ProtoMember(5)]
public DateTime StartTime { get; set; }
[ProtoMember(6)]
public double TransactionLength { get; set; }
}
}
最后,我必须将其作为 Observable Collection 接收并将其设置为 DataSet(以便将其保存为 XML 并在 DataGrid 中呈现)。我将不胜感激任何帮助和/或指向网络中适当材料的链接。 问候
【问题讨论】:
-
归根结底,这里的 protobuf-net 没有什么不同。任何向您展示如何通过套接字发送 byte[] 消息的示例就足够了。但是,我很确定源代码中有一个套接字项目示例 - 稍后会检查(而不是在 PC 上)
-
嗨,马克,感谢您的快速回复。
标签: c# communication protocol-buffers protobuf-net