예제 #1
0
 public void ConfigureSagas(ISagaRegistry sagaRegistry)
 {
     foreach (var sagaConfigInfo in sagaConventionConfigurationCache.ConfigurationInfos)
     {
         foreach (var typeToEventInfos in sagaConfigInfo.Value.Events)
         {
             foreach (var eventInfo in typeToEventInfos.Value)
             {
                 if (eventInfo.IsAlwaysStarting)
                 {
                     sagaRegistry.Add(SagaEventRegistration.AlwaysStarting(sagaConfigInfo.Key, typeToEventInfos.Key));
                 }
                 else if (eventInfo.SagaKey != null)
                 {
                     sagaRegistry.Add(SagaEventRegistration.MatchedByKey(sagaConfigInfo.Key, typeToEventInfos.Key,
                                                                         eventInfo.EventKeyExpression, eventInfo.SagaKey, eventInfo.IsStartingIfSagaNotFound));
                 }
                 else
                 {
                     sagaRegistry.Add(SagaEventRegistration.ToAllExistingInstances(sagaConfigInfo.Key, typeToEventInfos.Key, eventInfo.IsStartingIfSagaNotFound));
                 }
             }
         }
     }
 }
예제 #2
0
        public SagaTypeConfiguration <T> HandlesByKey <TEvent>(string sagaKey,
                                                               Expression <Func <TEvent, string> > eventKeyExpression, bool isStartingIfSagaNotFound = false) where TEvent : DomainEvent
        {
            var eventKeyExpressionFunc = eventKeyExpression.Compile();

            eventRegistrations.Add(SagaEventRegistration.MatchedByKey(typeof(T), typeof(TEvent),
                                                                      domainEvent => eventKeyExpressionFunc((TEvent)domainEvent),
                                                                      sagaKey, isStartingIfSagaNotFound));
            return(this);
        }
예제 #3
0
 public void Add(SagaEventRegistration sagaEventRegistration)
 {
     eventTypeRegistrations.Add(sagaEventRegistration.EventType, sagaEventRegistration);
 }
예제 #4
0
 public SagaTypeConfiguration <T> StartsWith <TEvent>() where TEvent : DomainEvent
 {
     eventRegistrations.Add(SagaEventRegistration.AlwaysStarting(typeof(T), typeof(TEvent)));
     return(this);
 }
예제 #5
0
 public SagaTypeConfiguration <T> HandlesAll <TEvent>(bool isStartingIfSagaNotFound = false) where TEvent : DomainEvent
 {
     eventRegistrations.Add(SagaEventRegistration.ToAllExistingInstances(typeof(T), typeof(TEvent),
                                                                         isStartingIfSagaNotFound));
     return(this);
 }