ISagaRegistrationConfigurator<T> IRegistrationConfigurator.AddSagaStateMachine<TStateMachine, T>(Type sagaDefinitionType) { ISagaRegistration Factory(IContainerRegistrar containerRegistrar) { SagaStateMachineRegistrationCache.Register(typeof(TStateMachine), containerRegistrar); if (sagaDefinitionType != null) SagaDefinitionRegistrationCache.Register(sagaDefinitionType, containerRegistrar); return new SagaStateMachineRegistration<T>(); } var registration = _sagaRegistrations.GetOrAdd(typeof(T), _ => Factory(_containerRegistrar)); return new SagaRegistrationConfigurator<T>(this, registration, _containerRegistrar); }
public ISagaRegistrationConfigurator <T> AddSagaStateMachine <TStateMachine, T>(Type sagaDefinitionType, Action <ISagaConfigurator <T> > configure = null) where TStateMachine : class, SagaStateMachine <T> where T : class, SagaStateMachineInstance { ISagaRegistration ValueFactory(Type type) { SagaStateMachineRegistrationCache.Register(typeof(TStateMachine), Registrar); return(new SagaStateMachineRegistration <T>()); } var registration = _sagas.GetOrAdd(typeof(T), ValueFactory); registration.AddConfigureAction(configure); if (sagaDefinitionType != null) { SagaDefinitionRegistrationCache.Register(sagaDefinitionType, Registrar); } return(new SagaRegistrationConfigurator <T>(this, Registrar)); }