Exemplo n.º 1
0
        /// <summary>
        /// 调用聚合根内部事件响应函数响应事件,更新聚合根的内部状态
        /// </summary>
        private void HandleEvent(object evnt)
        {
            var callback = _callbackProvider.GetInternalEventHandler(GetType(), evnt.GetType());

            if (callback != null)
            {
                callback(this, evnt);
            }
            else
            {
                UpdateAggregateRootAutomatically(evnt);
            }
        }
Exemplo n.º 2
0
        private void HandleEvent(IDomainEvent domainEvent)
        {
            if (_eventHandlerProvider == null)
            {
                _eventHandlerProvider = ObjectContainer.Resolve <IAggregateRootInternalHandlerProvider>();
            }
            var handler = _eventHandlerProvider.GetInternalEventHandler(GetType(), domainEvent.GetType());

            if (handler == null)
            {
                throw new Exception(string.Format("Could not find event handler for [{0}] of [{1}]", domainEvent.GetType().FullName, GetType().FullName));
            }
            handler(this, domainEvent);
        }
Exemplo n.º 3
0
        private void HandleEvent(IDomainEvent domainEvent)
        {
            if (_eventHandlerProvider == null)
            {
                _eventHandlerProvider = ObjectContainer.Resolve <IAggregateRootInternalHandlerProvider>();
            }
            var handler = _eventHandlerProvider.GetInternalEventHandler(GetType(), domainEvent.GetType());

            if (handler == null)
            {
                throw new Exception(string.Format("Could not find event handler for [{0}] of [{1}]", domainEvent.GetType().FullName, GetType().FullName));
            }
            if (Equals(this._id, default(TAggregateRootId)) && domainEvent.Version == 1)
            {
                this._id = TypeUtils.ConvertType <TAggregateRootId>(domainEvent.AggregateRootStringId);
            }
            handler(this, domainEvent);
        }
Exemplo n.º 4
0
        /// <summary>Handle the given event and update the aggregate status.
        /// </summary>
        private void HandleEvent <T>(T evnt) where T : class, IEvent
        {
            var eventHandler = this as IEventHandler <T>;

            if (eventHandler != null)
            {
                eventHandler.Handle(evnt);
            }
            else
            {
                var handler = _eventHandlerProvider.GetInternalEventHandler(this.GetType(), evnt.GetType());
                if (handler == null)
                {
                    throw new Exception(string.Format("Event handler not found on {0} for {1}.", this.GetType().FullName, evnt.GetType().FullName));
                }

                handler(this, evnt);
            }
        }