Beispiel #1
0
        public static ICommit Commit <T>(this EventMessage <T> message) where T : class
        {
            object commit;

            message.Headers.TryGetValue(NEventStoreMessageHeaders.Commit, out commit);

            return(commit as ICommit);
        }
        private static Task DispatchDomainEvent <TDomainEvent>(
            IHandlerResolver handlerModule,
            ICommit commit,
            int version,
            EventMessage eventMessage,
            CancellationToken cancellationToken)
            where TDomainEvent : class
        {
            var message = NEventStoreMessage.Create <TDomainEvent>(eventMessage, commit, version);

            return(handlerModule.Dispatch(message, cancellationToken));
        }
Beispiel #3
0
        public static EventMessage <T> Create <T>(EventMessage eventMessage, ICommit commit, int version) where T : class
        {
            var @event = (T)eventMessage.Body;

            var headers = new Dictionary <string, object>(commit.Headers).Merge(@eventMessage.Headers, new Dictionary <string, object>
            {
                { EventMessageHeaders.StreamId, commit.StreamId },
                { EventMessageHeaders.Type, typeof(T) },
                { NEventStoreMessageHeaders.Commit, commit }
            });

            return(new EventMessage <T>(commit.StreamId, @event, version, headers, commit.CheckpointToken));
        }