Protocol buffers Protobuf网络对Dictionary/KeyValuePair的支持是如何工作的?

Protocol buffers Protobuf网络对Dictionary/KeyValuePair的支持是如何工作的?,protocol-buffers,protobuf-net,Protocol Buffers,Protobuf Net,我试图理解protobuf net的字典/键值对支持。我们希望使用底层的二进制流和从java生成的proto文件,但是生成的.proto文件包含一个名为Pair\u String\u Int32的自定义类型 有人能解释一下吗 我有一个类映射如下: [DataContract] public class ForwardCurve { [DataMember(Order=1, IsRequired = true)] public string Commodity { get; set

我试图理解protobuf net的字典/键值对支持。我们希望使用底层的二进制流和从java生成的proto文件,但是生成的.proto文件包含一个名为Pair\u String\u Int32的自定义类型

有人能解释一下吗

我有一个类映射如下:

[DataContract]
public class ForwardCurve
{
    [DataMember(Order=1, IsRequired = true)]
    public string Commodity { get; set; }

    [DataMember(Order = 2, IsRequired = false)]
    public IDictionary<string, int> DictValue { get; set; }

    [DataMember(Order = 3, IsRequired = false)]
    public IList<string> ListValue { get; set; }

}

那么什么是Pair_String_Int32(以及进入protobuffer字节流的内容),有没有办法映射它,这样protobuf就可以使用protoc在Java中创建等价的映射代码呢?

我可以稍后检查(我现在在iPod上),但我相信它只是一个成员key=1 value=2的虚拟类型的“重复”集(使用每个-so c#string映射到proto string等的默认类型)。我正在重新实现GetProto for v2,因此我将尝试确保这些虚拟类型包含在输出中。

要获得此工作,请在生成的.proto文件中添加一条如下所示的新消息

message Pair_String_Int32 {
 required string Key = 1;
 required int32 Value = 2;    
}

然后protoc将能够为Java创建相应的代码。

我通过在生成的.proto文件中添加一条额外的消息来实现这一点。如果GetProto生成更加完整,那将是非常棒的。
message Pair_String_Int32 {
 required string Key = 1;
 required int32 Value = 2;    
}