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));
        }
Exemplo n.º 2
0
        void IRegistrationConfigurator.AddSaga(Type sagaType, Type sagaDefinitionType)
        {
            if (sagaType.HasInterface<SagaStateMachineInstance>())
                throw new ArgumentException($"State machine sagas must be registered using AddSagaStateMachine: {TypeMetadataCache.GetShortName(sagaType)}");

            _sagaRegistrations.GetOrAdd(sagaType, type => SagaRegistrationCache.CreateRegistration(type, sagaDefinitionType, _containerRegistrar));
        }
        public ISagaRegistrationConfigurator AddSaga(Type sagaType, Type sagaDefinitionType)
        {
            if (sagaType.HasInterface <SagaStateMachineInstance>())
            {
                throw new ArgumentException($"State machine sagas must be registered using AddSagaStateMachine: {TypeMetadataCache.GetShortName(sagaType)}");
            }

            return(SagaRegistrationCache.AddSaga(this, _sagaRepositoryRegistrationProvider, sagaType, sagaDefinitionType));
        }
Exemplo n.º 4
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);
        }
        public void AddSaga(Type sagaType, Type sagaDefinitionType)
        {
            if (sagaType.HasInterface <SagaStateMachineInstance>())
            {
                throw new ArgumentException($"State machine sagas must be registered using AddSagaStateMachine: {TypeMetadataCache.GetShortName(sagaType)}");
            }

            _sagas.GetOrAdd(sagaType, type => SagaRegistrationCache.CreateRegistration(type, Registrar));

            if (sagaDefinitionType != null)
            {
                SagaDefinitionRegistrationCache.Register(sagaDefinitionType, Registrar);
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 void IRegistrationConfigurator.AddSaga(Type sagaType, Type sagaDefinitionType)
 {
     _sagaRegistrations.GetOrAdd(sagaType, type => SagaRegistrationCache.CreateRegistration(type, sagaDefinitionType, _containerRegistrar));
 }