public IConsumerRegistrationConfigurator <T> AddConsumer <T>(Type consumerDefinitionType, Action <IConsumerConfigurator <T> > configure = null)
            where T : class, IConsumer
        {
            if (TypeMetadataCache <T> .HasSagaInterfaces)
            {
                throw new ArgumentException($"{TypeMetadataCache<T>.ShortName} is a saga, and cannot be registered as a consumer", nameof(T));
            }

            IConsumerRegistration ValueFactory(Type type)
            {
                ConsumerRegistrationCache.Register(type, Registrar);

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

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

            registration.AddConfigureAction(configure);

            if (consumerDefinitionType != null)
            {
                ConsumerDefinitionRegistrationCache.Register(consumerDefinitionType, Registrar);
            }

            return(new ConsumerRegistrationConfigurator <T>(this));
        }
        public IActivityRegistrationConfigurator <TActivity, TArguments, TLog> AddActivity <TActivity, TArguments, TLog>(Type activityDefinitionType,
                                                                                                                         Action <IExecuteActivityConfigurator <TActivity, TArguments> > configureExecute = null,
                                                                                                                         Action <ICompensateActivityConfigurator <TActivity, TLog> > configureCompensate = null)
            where TActivity : class, IActivity <TArguments, TLog>
            where TArguments : class
            where TLog : class
        {
            IActivityRegistration ValueFactory(Type type)
            {
                ActivityRegistrationCache.Register(type, Registrar);

                return(new ActivityRegistration <TActivity, TArguments, TLog>());
            }

            var registration = _activities.GetOrAdd(typeof(TActivity), ValueFactory);

            registration.AddConfigureAction(configureExecute);
            registration.AddConfigureAction(configureCompensate);

            if (activityDefinitionType != null)
            {
                ActivityDefinitionRegistrationCache.Register(activityDefinitionType, Registrar);
            }

            return(new ActivityRegistrationConfigurator <TActivity, TArguments, TLog>(this));
        }
        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));
        }
        public IExecuteActivityRegistrationConfigurator <TActivity, TArguments> AddExecuteActivity <TActivity, TArguments>(Type executeActivityDefinitionType,
                                                                                                                           Action <IExecuteActivityConfigurator <TActivity, TArguments> > configure = null)
            where TActivity : class, IExecuteActivity <TArguments>
            where TArguments : class
        {
            IExecuteActivityRegistration ValueFactory(Type type)
            {
                ExecuteActivityRegistrationCache.Register(type, Registrar);

                return(new ExecuteActivityRegistration <TActivity, TArguments>());
            }

            var registration = _executeActivities.GetOrAdd(typeof(TActivity), ValueFactory);

            registration.AddConfigureAction(configure);

            if (executeActivityDefinitionType != null)
            {
                ExecuteActivityDefinitionRegistrationCache.Register(executeActivityDefinitionType, Registrar);
            }

            return(new ExecuteActivityRegistrationConfigurator <TActivity, TArguments>(this));
        }
        public IFutureRegistrationConfigurator <TFuture> AddFuture <TFuture>(Type futureDefinitionType)
            where TFuture : MassTransitStateMachine <FutureState>
        {
            IFutureRegistration ValueFactory(Type type)
            {
                FutureRegistrationCache.Register(typeof(TFuture), Registrar);

                return(new FutureRegistration <TFuture>());
            }

            _futures.GetOrAdd(typeof(TFuture), ValueFactory);

            if (futureDefinitionType != null)
            {
                FutureDefinitionRegistrationCache.Register(futureDefinitionType, Registrar);
            }

            return(new FutureRegistrationConfigurator <TFuture>(this, Registrar));
        }
 public void AddEndpoint(Type definitionType)
 {
     _endpoints.GetOrAdd(definitionType, type => EndpointRegistrationCache.CreateRegistration(definitionType, Registrar));
 }