public void CreateSaga(Type sagaType, IReceiveEndpointConfigurator receiveEndpointConfigurator) { var stateMachineFactory = new DependencyInjectionSagaStateMachineFactory(_serviceProvider); var repositoryFactory = new DependencyInjectionStateMachineSagaRepositoryFactory(_serviceProvider); StateMachineSagaConfiguratorCache.Configure( sagaType, receiveEndpointConfigurator, stateMachineFactory, repositoryFactory); }
/// <summary> /// Subscribe a state machine saga to the endpoint /// </summary> /// <typeparam name="TInstance">The state machine instance type</typeparam> /// <param name="configurator"></param> /// <param name="scope">The StructureMap Container to resolve the repository</param> /// <param name="configure">Optionally configure the saga</param> /// <returns></returns> public static void StateMachineSaga <TInstance>(this IReceiveEndpointConfigurator configurator, IServiceProvider scope, Action <ISagaConfigurator <TInstance> > configure = null) where TInstance : class, SagaStateMachineInstance { ISagaStateMachineFactory stateMachineFactory = new DependencyInjectionSagaStateMachineFactory(scope); var stateMachine = stateMachineFactory.CreateStateMachine <TInstance>(); ISagaRepositoryFactory repositoryFactory = new DependencyInjectionStateMachineSagaRepositoryFactory(scope); var sagaRepository = repositoryFactory.CreateSagaRepository <TInstance>(); var stateMachineConfigurator = new StateMachineSagaConfigurator <TInstance>(stateMachine, sagaRepository, configurator); configure?.Invoke(stateMachineConfigurator); configurator.AddEndpointSpecification(stateMachineConfigurator); }