public ObjectDeserializationChecker(WireJsonSerializer serializer = null, CompareLogic logic = null) { _serializer = serializer ?? new WireJsonSerializer(); _compareLogic = logic ?? new CompareLogic { Config = new ComparisonConfig() }; }
public void Then_it_should_be_serialized_to_json() { var convertedItems = RawDataRepository.Load(_persistenceId); var serializer = new WireJsonSerializer(); var restoredFromJson = convertedItems.Select(i => serializer.FromBinary(i.Payload, Type.GetType(i.Manifest))); CollectionAssert.AllItemsAreNotNull(restoredFromJson); }
public void Test() { _original = (SampleDomainEvent) new SampleDomainEvent(1223, Guid.NewGuid()).CloneWithSaga(Guid.NewGuid()); var ser = new WireJsonSerializer(); var bytes = ser.ToBinary(_original); _restored = (SampleDomainEvent)ser.FromBinary(bytes, typeof(SampleDomainEvent)); }
public AggregateVersion <T>[] Load <T>(Guid id) where T : IAggregate { var serializer = new WireJsonSerializer(); using (var repo = new RawSnapshotsRepository(_writeString)) return(repo.Load(AggregateActorName.New <T>(id).Name) .Select(s => { var memento = (IMemento)serializer.FromBinary(s.Snapshot, typeof(IMemento)); var aggregate = (T)_aggregatesConstructor.Build(typeof(T), id, memento); aggregate.ClearUncommittedEvents(); //in case json will call public constructor return new AggregateVersion <T>(aggregate, s.Timestamp); }).ToArray()); }
public void Add <T>(T aggregate) where T : IAggregate { var serializer = new WireJsonSerializer(); using (var repo = new RawSnapshotsRepository(_writeString)) { var snapshot = aggregate.GetSnapshot(); var item = new SnapshotItem() { Manifest = snapshot.GetType().AssemblyQualifiedShortName(), PersistenceId = AggregateActorName.New <T>(aggregate.Id).Name, Snapshot = serializer.ToBinary(snapshot), Timestamp = BusinessDateTime.UtcNow }; repo.Save(item.PersistenceId, item); } }
private static T Deserialize <T>(byte[] source, WireJsonSerializer serializer = null) { return((T)(serializer ?? new WireJsonSerializer()).FromBinary(source, typeof(T))); }
private static byte[] Serialize(object source, WireJsonSerializer serializer = null) { return((serializer ?? new WireJsonSerializer()).ToBinary(source)); }