Example #1
0
        static ISagaRepository <TInstance> CreateSagaRepository <TInstance>(IContainer scope, Action <ConsumeContext> configureScope)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaRepositoryFactory repositoryFactory = new LamarSagaRepositoryFactory(scope, configureScope);

            return(repositoryFactory.CreateSagaRepository <TInstance>(AddStateMachineActivityFactory));
        }
Example #2
0
        public static void LoadFrom(this IReceiveEndpointConfigurator configurator, IContainer container)
        {
            var scopeProvider = new LamarConsumerScopeProvider(container);

            IList <Type> concreteTypes = FindTypes <IConsumer>(container, x => !x.HasInterface <ISaga>());

            if (concreteTypes.Count > 0)
            {
                foreach (var concreteType in concreteTypes)
                {
                    ConsumerConfiguratorCache.Configure(concreteType, configurator, scopeProvider);
                }
            }

            var sagaRepositoryFactory = new LamarSagaRepositoryFactory(container);

            IList <Type> sagaTypes = FindTypes <ISaga>(container, x => true);

            if (sagaTypes.Count > 0)
            {
                foreach (var sagaType in sagaTypes)
                {
                    SagaConfiguratorCache.Configure(sagaType, configurator, sagaRepositoryFactory);
                }
            }
        }
Example #3
0
        static ISagaRepository <TInstance> GetSagaRepository <TInstance>(IContainer container, Action <ConsumeContext> configureScope = null)
            where TInstance : class, ISaga
        {
            ISagaRepositoryFactory repositoryFactory = new LamarSagaRepositoryFactory(container);

            return(repositoryFactory.CreateSagaRepository <TInstance>(configureScope));
        }
        /// <summary>
        /// Registers a saga using the container that has the repository resolved from the container
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="container"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Saga <T>(this IReceiveEndpointConfigurator configurator, IContainer container, Action <ISagaConfigurator <T> > configure = null)
            where T : class, ISaga
        {
            ISagaRepositoryFactory factory = new LamarSagaRepositoryFactory(container);

            ISagaRepository <T> sagaRepository = factory.CreateSagaRepository <T>();

            configurator.Saga(sagaRepository, configure);
        }