Ejemplo n.º 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));
                 }
             }
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public void Add(SagaEventRegistration sagaEventRegistration)
 {
     eventTypeRegistrations.Add(sagaEventRegistration.EventType, sagaEventRegistration);
 }
Ejemplo n.º 4
0
 public SagaTypeConfiguration <T> StartsWith <TEvent>() where TEvent : DomainEvent
 {
     eventRegistrations.Add(SagaEventRegistration.AlwaysStarting(typeof(T), typeof(TEvent)));
     return(this);
 }
Ejemplo n.º 5
0
 public SagaTypeConfiguration <T> HandlesAll <TEvent>(bool isStartingIfSagaNotFound = false) where TEvent : DomainEvent
 {
     eventRegistrations.Add(SagaEventRegistration.ToAllExistingInstances(typeof(T), typeof(TEvent),
                                                                         isStartingIfSagaNotFound));
     return(this);
 }