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 async Task Add<T>(T aggregate) where T : class, IAggregate
 {
     using (var repo = new RawSnapshotsRepository(option))
     {
         var snapshot = _snapshotsConstructor.GetSnapshot(aggregate);
         var item = new SnapshotItem
                    {
                        Manifest = snapshot.GetType().AssemblyQualifiedShortName(),
                        PersistenceId = EntityActorName.New<T>(aggregate.Id).Name,
                        Snapshot = new DomainSerializer().ToBinary(snapshot),
                        Timestamp = BusinessDateTime.UtcNow
                    };
         await repo.Save(item.PersistenceId, item);
     }
 }
        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);
            }
        }
        public async Task<Version<T>[]> Load<T>(string id) where T : class, IAggregate
        {
            var snapshotType = _snapshotsConstructor.GetSnapshot(_aggregatesConstructor.BuildEmpty<T>())
                                                    .GetType();

            var serializer = new DomainSerializer();
            
            using (var snapshotItemsRepo = new RawSnapshotsRepository(option))
            {
                return (await snapshotItemsRepo.Load(EntityActorName.New<T>(id).
                                                           Name)).Select(s =>
                                                                         {
                                                                             var memento = (IMemento) serializer.FromBinary(s.Snapshot, snapshotType);
                                                                             var aggregate = (T) _aggregatesConstructor.Build(typeof(T), id, memento);
                                                                             return new Version<T>(aggregate, s.Timestamp);
                                                                         }).
                                                                  ToArray();
            }
        }