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