Esempio n. 1
0
        public void Dispatch <TEventData>(TEventData eventData, string type = null, IDictionary <string, string> metadata = null) where TEventData : class, IDomainEvent
        {
            var domainEvent = DomainEventDescriptor.CreateNew(Type, Id.ToString(), eventData, ++Version, type);

            if (metadata != null)
            {
                foreach (var keyValue in metadata)
                {
                    metadata.Add(keyValue);
                }
            }

            OnEvent(eventData);

            _domainEvents.Add(domainEvent);
            IsVersionSync = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Mark aggregate as deleted
        /// </summary>
        /// <param name="aggregate"></param>
        public void Remove(TKey aggregateId)
        {
            var removeEvent = DomainEventDescriptor.CreateNew(AggregateType, aggregateId.ToString(), new RemoveAggregateRootEvent(aggregateId.ToString()), DomainEventDescriptor.UnknowVersion);

            _domainEvents.Add(removeEvent);
        }