static ISagaRepository <TInstance> CreateSagaRepository <TInstance>(IWindsorContainer container)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaRepositoryFactory repositoryFactory = new WindsorSagaRepositoryFactory(container.Kernel);

            return(repositoryFactory.CreateSagaRepository <TInstance>(AddStateMachineActivityFactory));
        }
        static ISagaRepository <TInstance> ResolveSagaRepository <TInstance>(this IKernel kernel)
            where TInstance : class, ISaga
        {
            ISagaRepositoryFactory repositoryFactory = new WindsorSagaRepositoryFactory(kernel);

            return(repositoryFactory.CreateSagaRepository <TInstance>());
        }
Пример #3
0
        /// <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="kernel"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Saga <T>(this IReceiveEndpointConfigurator configurator, IKernel kernel, Action <ISagaConfigurator <T> > configure = null)
            where T : class, ISaga
        {
            ISagaRepositoryFactory factory = new WindsorSagaRepositoryFactory(kernel);

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

            configurator.Saga(sagaRepository, configure);
        }
Пример #4
0
        public static void LoadFrom(this IReceiveEndpointConfigurator configurator, IKernel kernel)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

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

            if (consumerTypes.Count > 0)
            {
                var scopeProvider = new WindsorConsumerScopeProvider(kernel);

                foreach (var type in consumerTypes)
                {
                    ConsumerConfiguratorCache.Configure(type, configurator, scopeProvider);
                }
            }

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

            if (sagaTypes.Count > 0)
            {
                var repositoryFactory = new WindsorSagaRepositoryFactory(kernel);

                foreach (var sagaType in sagaTypes)
                {
                    SagaConfiguratorCache.Configure(sagaType, configurator, repositoryFactory);
                }
            }
        }