Exemple #1
0
        /// <summary>
        /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the Autofac saga repository
        /// and the appropriate state machine saga repository under the hood.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="context"></param>
        /// <param name="name"></param>
        /// <param name="configureScope">Configuration for scope container</param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IComponentContext context, string name = "message",
                                                 Action <ContainerBuilder, ConsumeContext> configureScope = null)
        {
            var registration = context.ResolveOptional <IRegistration>();

            if (registration != null)
            {
                registration.ConfigureSagas(configurator);

                return;
            }

            var scope = context.Resolve <ILifetimeScope>();

            IEnumerable <Type> sagaTypes = FindStateMachineSagaTypes(context);

            var stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            var scopeProvider     = new SingleLifetimeScopeProvider(scope);
            var repositoryFactory = new AutofacSagaRepositoryFactory(scopeProvider, name, configureScope);
            var activityFactory   = new AutofacStateMachineActivityFactory();

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, stateMachineFactory, repositoryFactory, activityFactory);
            }
        }
        /// <summary>
        /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the Autofac saga repository
        /// and the appropriate state machine saga repository under the hood.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="container"></param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IContainer container)
        {
            IList <Type> sagaTypes = FindStateMachineSagaTypes(container);

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, container);
            }
        }
Exemple #3
0
        public void CreateSaga(Type sagaType, IReceiveEndpointConfigurator receiveEndpointConfigurator)
        {
            var stateMachineFactory = new DependencyInjectionSagaStateMachineFactory(_serviceProvider);
            var repositoryFactory   = new DependencyInjectionStateMachineSagaRepositoryFactory(_serviceProvider);

            StateMachineSagaConfiguratorCache.Configure(
                sagaType,
                receiveEndpointConfigurator,
                stateMachineFactory,
                repositoryFactory);
        }
        /// <summary>
        /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the Autofac saga repository
        /// and the appropriate state machine saga repository under the hood.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="context"></param>
        /// <param name="name"></param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IComponentContext context, string name = "message")
        {
            var scope = context.Resolve <ILifetimeScope>();

            IList <Type> sagaTypes = FindStateMachineSagaTypes(context);

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, scope, name);
            }
        }
        /// <summary>
        /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the StructureMap saga repository
        /// and the appropriate state machine saga repository under the hood.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="container"></param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IContainer container)
        {
            IList <Type> sagaTypes = FindStateMachineSagaTypes(container);

            var stateMachineFactory = new LamarSagaStateMachineFactory(container);

            var repositoryFactory = new LamarStateMachineSagaRepositoryFactory(container);

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, stateMachineFactory, repositoryFactory);
            }
        }
        /// <summary>
        /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the Autofac saga repository
        /// and the appropriate state machine saga repository under the hood.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="context"></param>
        /// <param name="name"></param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IComponentContext context, string name = "message")
        {
            var scope = context.Resolve <ILifetimeScope>();

            IEnumerable <Type> sagaTypes = FindStateMachineSagaTypes(context);

            var stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            var scopeProvider     = new SingleLifetimeScopeProvider(scope);
            var repositoryFactory = new AutofacStateMachineSagaRepositoryFactory(scopeProvider, name);

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, stateMachineFactory, repositoryFactory);
            }
        }
        /// <summary>
        /// Specify that the service bus should load the StateMachineSagas from the container passed as argument
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="container"></param>
        public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IKernel container)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            IEnumerable <Type> sagaTypes = FindStateMachineSagaTypes(container);

            var stateMachineFactory = new WindsorSagaStateMachineFactory(container);

            var repositoryFactory = new WindsorStateMachineSagaRepositoryFactory(container);

            foreach (var sagaType in sagaTypes)
            {
                StateMachineSagaConfiguratorCache.Configure(sagaType, configurator, stateMachineFactory, repositoryFactory);
            }
        }