private SnapshotEntry ToSnapshotEntry(SnapshotMetadata metadata, object snapshot) { if (_settings.LegacySerialization) { var manifest = snapshot.GetType().TypeQualifiedName(); return(new SnapshotEntry { Id = metadata.PersistenceId + "_" + metadata.SequenceNr, PersistenceId = metadata.PersistenceId, SequenceNr = metadata.SequenceNr, Snapshot = snapshot, Timestamp = metadata.Timestamp.Ticks, Manifest = manifest, SerializerId = null }); } var snapshotRep = new Akka.Persistence.Serialization.Snapshot(snapshot); var serializer = _serialization.FindSerializerFor(snapshotRep); var binary = serializer.ToBinary(snapshotRep); var binaryManifest = Akka.Serialization.Serialization.ManifestFor(serializer, snapshotRep); return(new SnapshotEntry { Id = metadata.PersistenceId + "_" + metadata.SequenceNr, PersistenceId = metadata.PersistenceId, SequenceNr = metadata.SequenceNr, Snapshot = binary, Timestamp = metadata.Timestamp.Ticks, Manifest = binaryManifest, SerializerId = serializer?.Identifier }); }
private SnapshotEntry ToSnapshotEntry(SnapshotMetadata metadata, object snapshot) { var snapshotRep = new Akka.Persistence.Serialization.Snapshot(snapshot); var serializer = _serialization.FindSerializerFor(snapshotRep); var binary = serializer.ToBinary(snapshotRep); var manifest = ""; if (serializer is SerializerWithStringManifest stringManifest) { manifest = stringManifest.Manifest(snapshotRep); } else { manifest = snapshotRep.GetType().TypeQualifiedName(); } return(new SnapshotEntry { Id = metadata.PersistenceId + "_" + metadata.SequenceNr, PersistenceId = metadata.PersistenceId, SequenceNr = metadata.SequenceNr, Snapshot = binary, Timestamp = metadata.Timestamp.Ticks, Manifest = manifest, SerializerId = serializer?.Identifier }); }
public void SnapshotSerializer_should_handle_custom_snapshot_Serialization_with_string_manifest() { var wrapped = new Akka.Persistence.Serialization.Snapshot(new MySnapshot2("a")); var serializer = _serialization.FindSerializerFor(wrapped); var bytes = serializer.ToBinary(wrapped); var deserialized = serializer.FromBinary(bytes, null); deserialized.ShouldBe(new Akka.Persistence.Serialization.Snapshot(new MySnapshot2(".a."))); }
public void SnapshotSerializer_should_handle_custom_snapshot_Serialization_with_string_manifest() { var wrapped = new Akka.Persistence.Serialization.Snapshot(new MySnapshot2("a")); var serializer = _serialization.FindSerializerFor(wrapped); var bytes = serializer.ToBinary(wrapped); var deserialized = serializer.FromBinary(bytes, null); deserialized.ShouldBe(new Akka.Persistence.Serialization.Snapshot(new MySnapshot2(".a."))); }