public static void StoreEvent <TEvent>(this IEventSession session, TEvent @event, EventStreamId id, ILocalMachine localMachine) where TEvent : new() { session.StoreEvent(new SourcedEvent { Body = @event }, id); session.StoreHeader(id, EventOriginHeader.Key, EventOriginHeader.ForMachine(localMachine)); }
public void Save <TAggregateRoot>(TAggregateRoot aggregateRoot) where TAggregateRoot : AggregateRoot { using (IEventSession eventSession = eventSessionFactory.Create()) { foreach (SourcedEvent @event in aggregateRoot.EventsAdded) { EventStreamId eventStreamId = aggregateRoot.GetEventStreamId(); eventSession.StoreEvent(@event, eventStreamId); eventSession.StoreHeader(eventStreamId, EventOriginHeader.Key, EventOriginHeader.ForMachine(localMachine)); } eventSession.Commit(Guid.NewGuid()); } }
public void GivenIAddAnEventOriginForTheLocalMachineAsAHeaderToTheEventSession(Guid streamId, string bucketId) { session.StoreHeader(new EventStreamId(streamId.ToString(), bucketId), EventOriginHeader.Key, new EventOriginHeader { MachineName = System.Environment.MachineName }); }