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; }
/// <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); }