J'ai créé un fichier .proto et le fichier .cs créé avec succès par ProtoBufTool. Je suis un peu nouveau à csharp et j'essaye de placer les champs d'extension. Mais je ne sais pas comment le faire? Quelqu'un a-t-il des exemples d'utilisation des extensions avec protobuf-net?Comment utiliser les extensions de protobuf-net?
Mon fichier .proto:
package messages;
message DMsg
{
optional int32 msgtype = 1;
extensions 100 to max;
}
extend DMsg
{
optional string fltColumns = 101;
}
Voici la classe qui a obtenu créé:
//------------------------------------------------------------------------------
//
// 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); }
}
}
avez-vous un exemple qui montre comment définir des valeurs et d'obtenir des valeurs? – VNarasimhaM
@VNarasimhaM - ajouté par demande –