Exemple #1
0
        /// <summary>
        /// Saves the provided <paramref name="event"/>.
        /// </summary>
        /// <param name="aggregateRootType"> <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> the <see cref="IEvent{TAuthenticationToken}"/> was raised in.</param>
        /// <param name="event">The <see cref="IEvent{TAuthenticationToken}"/> to be saved.</param>
        public virtual void Save(Type aggregateRootType, IEvent <TAuthenticationToken> @event)
        {
            Logger.LogDebug(string.Format("Saving aggregate root event type '{0}'", @event.GetType().FullName), string.Format("{0}\\Save", GetType().Name));
            EventData eventData  = EventBuilder.CreateFrameworkEvent(@event);
            string    streamName = GenerateStreamName(aggregateRootType, @event);

            eventData.AggregateId   = streamName;
            eventData.AggregateRsn  = @event.Id;
            eventData.Version       = @event.Version;
            eventData.CorrelationId = @event.CorrelationId;
            PersistEvent(eventData);
            Logger.LogInfo(string.Format("Saving aggregate root event type '{0}'... done", @event.GetType().FullName), string.Format("{0}\\Save", GetType().Name));
            TelemetryHelper.TrackMetric(string.Format("Cqrs/EventStore/Save/{0}", streamName), 1);
        }