public Account Get(IHaveIdentity id)
 {
     var snapshot = documentStore.Get<AccountSnapshot>(id.GetSurrogateId());
     var account = ActivatorHelper.CreateInstance<Account>();
     ((IAggregate)account).RestoreSnapshot(snapshot);
     return account;
 }
        public void Add(IHaveIdentity projection)
        {
            if (projection == null)
            {
                throw new ArgumentNullException(nameof(projection));
            }

            // Do nothing.
        }
        protected TEntity Get <TEntity>(IHaveIdentity entityId) where TEntity : IEntity
        {
            var entity = Entities.SingleOrDefault(e => e.Identity.Equals(entityId));

            if (entity == null)
            {
                throw new InvalidOperationException(String.Format("Entity {0} could not be found on aggregate {1}", entityId, Identity));
            }

            return((TEntity)entity);
        }
        public Account Get(IHaveIdentity id)
        {
            IEventStream eventStream = eventStore.OpenStream(id.GetSurrogateId());

            if (!eventStream.CommittedEvents.Any())
            {
                throw new InvalidOperationException("Unable to find any events for the provided aggregate key.");
            }

            var events = eventStream.CommittedEvents.Select(message => (IDomainEvent)message.Body);

            var account = ActivatorHelper.CreateInstance<Account>();
            ((IAggregate)account).LoadFromHistory(events);

            return account;
        }
 protected Aggregate(IHaveIdentity identity)
     : base(identity)
 {
 }
Beispiel #6
0
 protected EntityBase(IHaveIdentity identity)
 {
     Identity      = identity;
     eventHandlers = new Dictionary <Type, Action <object> >();
     ScanForEventHandlers();
 }
Beispiel #7
0
 protected EntityBase(IHaveIdentity identity)
 {
     Identity = identity;
 }
 protected EntityBase(IHaveIdentity identity)
 {
     Identity = identity;
 }
 protected Entity(Aggregate parent, IHaveIdentity identity)
     : base(identity)
 {
     SetParent(parent);
 }
 protected EntityBase(IHaveIdentity identity)
 {
     Identity = identity;
     eventHandlers = new Dictionary<Type, Action<object>>();
     ScanForEventHandlers();
 }
 public void Add(IHaveIdentity projection)
 {
     cache.Add(projection);
 }
Beispiel #12
0
 protected Entity(Aggregate parent, IHaveIdentity identity)
     : base(identity)
 {
     SetParent(parent);
 }