コード例 #1
0
ファイル: LotEventDispatcher.cs プロジェクト: MartinBG/Gva
 public void Dispatch(ILotEvent e)
 {
     foreach (var handler in this.handlers)
     {
         handler.Handle(e);
     }
 }
コード例 #2
0
        protected void ThrowOnWrongEvent(ILotEvent e)
        {
            var id = new System.Text.StringBuilder();

            id.Append("[").Append("Lot|");

            var stateEntityId = this.LotId; // Aggregate Id
            var eventEntityId = e.LotEventId.LotId;

            if (stateEntityId != eventEntityId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id {0} in state but entity id {1} in event", stateEntityId, eventEntityId);
            }
            id.Append(stateEntityId).Append(",");

            id.Append("]");

            var stateVersion = this.Version;
            var eventVersion = e.LotEventId.Version;

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
コード例 #3
0
 public virtual LotStateCreatedOrMergePatchedOrDeletedDto ToLotStateEventDto(ILotEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (ILotStateCreated)stateEvent;
         return(ToLotStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (ILotStateMergePatched)stateEvent;
         return(ToLotStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (ILotStateDeleted)stateEvent;
         return(ToLotStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
コード例 #4
0
ファイル: MockLotEventHandler.cs プロジェクト: MartinBG/Gva
 public void Handle(ILotEvent e)
 {
     this.Event = e;
 }
コード例 #5
0
 public void AddLotEvent(ILotEvent e)
 {
     _innerStateEvents.Add((LotStateCreatedOrMergePatchedOrDeletedDto)e);
 }