Exemple #1
0
        protected void ConfigureRegistration <T>(IRegistrationConfigurator <T> configurator)
        {
            configurator.AddSaga <SimpleSaga>()
            .Endpoint(e => e.Name = "custom-endpoint-name")
            .InMemoryRepository();

            configurator.AddSaga <SecondSimpleSaga>(typeof(SecondSimpleSagaDefinition))
            .Endpoint(e => e.Temporary = true)
            .InMemoryRepository();

            configurator.AddBus(provider => BusControl);
        }
 /// <summary>
 /// Adds the saga, allowing configuration when it is configured on the endpoint. This should not
 /// be used for state machine (Automatonymous) sagas.
 /// </summary>
 /// <param name="configurator"></param>
 /// <param name="configure"></param>
 /// <typeparam name="T">The saga type</typeparam>
 /// <typeparam name="TDefinition">The saga definition type</typeparam>
 public static ISagaRegistrationConfigurator <T> AddSaga <T, TDefinition>(this IRegistrationConfigurator configurator,
                                                                          Action <ISagaConfigurator <T> > configure = null)
     where T : class, ISaga
     where TDefinition : class, ISagaDefinition <T>
 {
     return(configurator.AddSaga(typeof(TDefinition), configure));
 }
Exemple #3
0
        protected void ConfigureRegistration <T>(IRegistrationConfigurator <T> configurator)
        {
            configurator.AddSaga <SimpleSaga>()
            .InMemoryRepository();

            configurator.AddBus(provider => BusControl);
        }
Exemple #4
0
        protected void ConfigureRegistration <T>(IRegistrationConfigurator <T> configurator)
        {
            configurator.AddSaga <SimpleSaga>()
            .Endpoint(e => e.Name = "custom-endpoint-name")
            .InMemoryRepository();

            configurator.AddBus(provider => BusControl);
        }
Exemple #5
0
        protected void ConfigureRegistration <T>(IRegistrationConfigurator <T> configurator)
        {
            configurator.AddConsumer <OrderConsumer>();
            configurator.AddSaga <OrderSaga>()
            .InMemoryRepository();

            configurator.AddMediator();
        }
        /// <summary>
        /// Adds the specified saga types
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="types">The state machine types to add</param>
        public static void AddSagas(this IRegistrationConfigurator configurator, params Type[] types)
        {
            IEnumerable <Type> sagaTypes           = types.Where(x => x.HasInterface <ISaga>());
            IEnumerable <Type> sagaDefinitionTypes = types.Where(x => x.HasInterface(typeof(ISagaDefinition <>)));

            var sagas = from c in sagaTypes
                        join d in sagaDefinitionTypes on c equals d.GetClosingArgument(typeof(ISagaDefinition <>)) into dc
                        from d in dc.DefaultIfEmpty()
                        select new { SagaType = c, DefinitionType = d };

            foreach (var saga in sagas)
            {
                configurator.AddSaga(saga.SagaType, saga.DefinitionType);
            }
        }
Exemple #7
0
        /// <summary>
        /// Adds a SagaStateMachine to the registry, using the factory method, and updates the registrar prior to registering so that the default
        /// saga registrar isn't notified.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="registrar"></param>
        /// <param name="sagaDefinitionType"></param>
        /// <typeparam name="TStateMachine"></typeparam>
        /// <typeparam name="TInstance"></typeparam>
        public static ISagaRegistrationConfigurator <TInstance> AddSagaStateMachine <TStateMachine, TInstance>(this IRegistrationConfigurator configurator,
                                                                                                               ISagaStateMachineRegistrar registrar, Type sagaDefinitionType = null)
            where TStateMachine : class, SagaStateMachine <TInstance>
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaRegistration Factory(IContainerRegistrar containerRegistrar)
            {
                SagaStateMachineRegistrationCache.Register(typeof(TStateMachine), registrar);

                if (sagaDefinitionType != null)
                {
                    SagaDefinitionRegistrationCache.Register(sagaDefinitionType, containerRegistrar);
                }

                return(new SagaStateMachineRegistration <TInstance>());
            }

            return(configurator.AddSaga <TInstance>(Factory));
        }