.proto 파일을 만들고 ProtoBufTool이 .cs 파일을 만들었습니다. 나는 좀 새로운 csharp이고 확장 필드를 설정하려고합니다. 그러나 그것을하는 방법을 모르십니까? protobuf-net을 사용하여 확장 기능을 사용하는 방법에 대한 사례가있는 사람이 있습니까? protobuf-net 확장 기능을 사용 하시겠습니까?
내 .proto 파일 : 여기package messages;
message DMsg
{
optional int32 msgtype = 1;
extensions 100 to max;
}
extend DMsg
{
optional string fltColumns = 101;
}
가 생성되었다 클래스입니다 :
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
// Generated from: message.proto
namespace messages
{
[global::System.Serializable, global::ProtoBuf.ProtoContract([email protected]"DMsg")]
public partial class DMsg : global::ProtoBuf.IExtensible
{
public DMsg() {}
private int _msgtype = default(int);
[global::ProtoBuf.ProtoMember(1, IsRequired = false, [email protected]"msgtype", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)][global::System.ComponentModel.DefaultValue(default(int))]
public int msgtype
{
get { return _msgtype; }
set { _msgtype = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
}
당신은 값을 설정하고 값을 가져 오는 방법을 보여줍니다 예를해야합니까? – VNarasimhaM
@VNarasimhaM - 요청 당 추가 –