public ISagaRegistrationConfigurator <T> AddSaga <T>(Type sagaDefinitionType, Action <ISagaConfigurator <T> > configure = null)
            where T : class, ISaga
        {
            if (typeof(T).HasInterface <SagaStateMachineInstance>())
            {
                throw new ArgumentException($"State machine sagas must be registered using AddSagaStateMachine: {TypeMetadataCache<T>.ShortName}");
            }

            ISagaRegistration ValueFactory(Type type)
            {
                SagaRegistrationCache.Register(type, Registrar);

                return(new SagaRegistration <T>());
            }

            var registration = _sagas.GetOrAdd(typeof(T), ValueFactory);

            registration.AddConfigureAction(configure);

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

            return(new SagaRegistrationConfigurator <T>(this, Registrar));
        }
Example #2
0
        void IRegistrationConfigurator.AddSaga <T>(Action <ISagaConfigurator <T> > configure)
        {
            ISagaRegistration ValueFactory(Type type)
            {
                SagaRegistrationCache.Register(type, _containerRegistrar);

                return(new SagaRegistration <T>());
            }

            var configurator = _sagaConfigurations.GetOrAdd(typeof(T), ValueFactory);

            configurator.AddConfigureAction(configure);
        }
Example #3
0
        ISagaRegistrationConfigurator<T> IRegistrationConfigurator.AddSaga<T>(Action<ISagaConfigurator<T>> configure)
        {
            if (typeof(T).HasInterface<SagaStateMachineInstance>())
                throw new ArgumentException($"State machine sagas must be registered using AddSagaStateMachine: {TypeMetadataCache<T>.ShortName}");

            ISagaRegistration ValueFactory(Type type)
            {
                SagaRegistrationCache.Register(type, _containerRegistrar);

                return new SagaRegistration<T>();
            }

            var registration = _sagaRegistrations.GetOrAdd(typeof(T), ValueFactory);

            registration.AddConfigureAction(configure);

            return new SagaRegistrationConfigurator<T>(this, registration, _containerRegistrar);
        }