예제 #1
0
        public void Apply(EntityDomainEvent domainEvent)
        {
            domainEvent.EntityId = Id;

            if (!((IHaveATestMode) this).IsInTestMode)
                AggregateRoot.Apply(domainEvent);

            _uncommittedEvents.Enqueue(domainEvent);
            ApplyEventToInternalState(domainEvent);
        }
예제 #2
0
        //
        // TODO: Cache event handler
        //
        private void ApplyEventToInternalState(EntityDomainEvent domainEvent)
        {
            var domainEventType = domainEvent.GetType();
            var domainEventTypeName = domainEventType.Name;
            var entityType = GetType();

            var methodInfo = entityType.GetMethod(GetEventHandlerMethodName(domainEventTypeName),
                BindingFlags.Instance | BindingFlags.Public |
                BindingFlags.NonPublic, null, new[] {domainEventType}, null);

            if (methodInfo == null || !EventHandlerMethodInfoHasCorrectParameter(methodInfo, domainEventType)) return;

            methodInfo.Invoke(this, new[] {domainEvent});
        }