コード例 #1
0
 /// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary>
 public static MessageRegister Deserialize(byte[] buffer)
 {
     var instance = new MessageRegister();
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
コード例 #2
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static MessageRegister DeserializeLength(Stream stream, int length)
 {
     var instance = new MessageRegister();
     DeserializeLength(stream, length, instance);
     return instance;
 }
コード例 #3
0
 /// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary>
 public static byte[] SerializeToBytes(MessageRegister instance)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(ms, instance);
         return ms.ToArray();
     }
 }
コード例 #4
0
 /// <summary>Helper: Serialize with a varint length prefix</summary>
 public static void SerializeLengthDelimited(Stream stream, MessageRegister instance)
 {
     var data = SerializeToBytes(instance);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
     stream.Write(data, 0, data.Length);
 }
コード例 #5
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static MessageRegister Deserialize(Stream stream)
 {
     var instance = new MessageRegister();
     Deserialize(stream, instance);
     return instance;
 }
コード例 #6
0
 /// <summary>Serialize the instance into the stream</summary>
 public static void Serialize(Stream stream, MessageRegister instance)
 {
     var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
     if (instance.Id == null)
         throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Id is required by the proto specification.");
     // Key for field: 1, LengthDelimited
     stream.WriteByte(10);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Id));
     // Key for field: 2, Varint
     stream.WriteByte(16);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.DiskSpace);
     // Key for field: 3, Varint
     stream.WriteByte(24);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.BlockNum);
     if (instance.DataAddr == null)
         throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("DataAddr is required by the proto specification.");
     // Key for field: 4, LengthDelimited
     stream.WriteByte(34);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.DataAddr));
     // Key for field: 5, Varint
     stream.WriteByte(40);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.DataPort);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
 }
コード例 #7
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static MessageRegister DeserializeLengthDelimited(Stream stream)
 {
     var instance = new MessageRegister();
     DeserializeLengthDelimited(stream, instance);
     return instance;
 }