Exemple #1
0
        public static void StoreEvent <TEvent>(this IEventSession session, Action <TEvent> eventIntialiser, EventStreamId id, ILocalMachine localMachine)
            where TEvent : new()
        {
            var @event = new TEvent();

            eventIntialiser(@event);
            session.StoreEvent(@event, id, localMachine);
        }
Exemple #2
0
 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 GivenIHaveCreatedAnEventInTheSessionWithAnIdOfForTheStreamIdentifiedAs(Guid id, Guid streamId, string bucketId)
 {
     session.StoreEvent(new SourcedEvent {
         Body = new TestEvent {
             Id = id
         }
     }, new EventStreamId(streamId.ToString(), bucketId));
 }
        void OnDuplicateCommitButtonClick(object sender, EventArgs eventArgs)
        {
            Guid commitId = Guid.NewGuid();
            var  factory  = container.Resolve <IEventSessionFactory>();

            IEventSession session = factory.Create();

            session.StoreEvent(new SourcedEvent {
                Body = new TestEvent()
            }, new EventStreamId("Test", "Test"));
            session.Commit(commitId);
            session.Commit(commitId);
        }
Exemple #5
0
        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());
            }
        }
Exemple #6
0
 public static void StoreEventAndCommit <TEvent>(this IEventSession session, TEvent @event, EventStreamId id, ILocalMachine localMachine)
     where TEvent : new()
 {
     session.StoreEvent(@event, id, localMachine);
     session.Commit(Guid.NewGuid());
 }