/// <summary>
 /// Deserialize a <see cref="Mutation"/> from binary data.
 /// </summary>
 /// <param name="data">The binary data to deserialize.</param>
 /// <returns>The deserialized <see cref="Mutation"/>.</returns>
 public static Mutation DeserializeMutation(ByteString data)
 {
     Messages.Mutation mutation = new Messages.Mutation();
     mutation.MergeFrom(data.ToProtocolBuffers());
     
     return new Mutation(
         new ByteString(mutation.Namespace.ToByteArray()),
         mutation.Records.Select(
             record => new Record(
                 new ByteString(record.Key.ToByteArray()),
                 record.Value != null ? new ByteString(record.Value.Data.ToByteArray()) : null,
                 new ByteString(record.Version.ToByteArray()))),
         new ByteString(mutation.Metadata.ToByteArray()));
 }
Esempio n. 2
0
 /// <summary>
 /// Deserialize a <see cref="Mutation"/> from binary data.
 /// </summary>
 /// <param name="data">The binary data to deserialize.</param>
 /// <returns>The deserialized <see cref="Mutation"/>.</returns>
 public static Mutation DeserializeMutation(ByteString data)
 {
     Messages.Mutation mutation = new Messages.Mutation();
     mutation.MergeFrom(data.ToProtocolBuffers());
     
     return new Mutation(
         new ByteString(Google.Protobuf.ByteString.Unsafe.GetBuffer(mutation.Namespace)),
         mutation.Records.Select(
             record => new Record(
                 new ByteString(Google.Protobuf.ByteString.Unsafe.GetBuffer(record.Key)),
                 record.Value != null ? new ByteString(Google.Protobuf.ByteString.Unsafe.GetBuffer(record.Value.Data)) : null,
                 new ByteString(Google.Protobuf.ByteString.Unsafe.GetBuffer(record.Version)))),
         new ByteString(Google.Protobuf.ByteString.Unsafe.GetBuffer(mutation.Metadata)));
 }