Esempio n. 1
0
        static ISagaRepository <TInstance> CreateSagaRepository <TInstance>(ILifetimeScope scope, string name,
                                                                            Action <ContainerBuilder, ConsumeContext> configureScope)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaRepositoryFactory repositoryFactory = new AutofacSagaRepositoryFactory(new SingleLifetimeScopeProvider(scope), name, configureScope);

            return(repositoryFactory.CreateSagaRepository <TInstance>(AddStateMachineActivityFactory));
        }
        static ISagaRepository <TInstance> ResolveSagaRepository <TInstance>(this ILifetimeScope scope, string name = "message",
                                                                             Action <ContainerBuilder, ConsumeContext> configureScope = null)
            where TInstance : class, ISaga
        {
            ISagaRepositoryFactory repositoryFactory = new AutofacSagaRepositoryFactory(new SingleLifetimeScopeProvider(scope), name, configureScope);

            return(repositoryFactory.CreateSagaRepository <TInstance>());
        }
        /// <summary>
        /// Registers a saga using the container that has the repository resolved from the container
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="scope"></param>
        /// <param name="name"></param>
        /// <param name="configureScope">Configuration for scope container</param>
        /// <returns></returns>
        public static void Saga <T>(this IReceiveEndpointConfigurator configurator, ILifetimeScope scope, string name = "message",
                                    Action <ContainerBuilder, ConsumeContext> configureScope = null)
            where T : class, ISaga
        {
            ISagaRepositoryFactory factory = new AutofacSagaRepositoryFactory(new SingleLifetimeScopeProvider(scope), name, configureScope);

            ISagaRepository <T> sagaRepository = factory.CreateSagaRepository <T>();

            configurator.Saga(sagaRepository);
        }