/// <summary> /// Specify that the service bus should load the StateMachineSagas from the container passed as argument /// </summary> /// <param name="configurator"></param> /// <param name="container"></param> public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IKernel container) { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } if (container == null) { throw new ArgumentNullException(nameof(container)); } var registrationConfigurator = new RegistrationConfigurator(); container.Register(Component.For <ISagaStateMachineFactory>().Instance(new WindsorSagaStateMachineFactory(container))); container.Register(Component.For <IStateMachineActivityFactory>().Instance(new WindsorStateMachineActivityFactory())); container.Register(Component.For <ISagaRepositoryFactory>().Instance(new WindsorSagaRepositoryFactory(container))); IEnumerable <Type> sagaTypes = FindStateMachineSagaTypes(container); foreach (var sagaType in sagaTypes) { SagaStateMachineRegistrationCache.AddSagaStateMachine(registrationConfigurator, sagaType); } var registration = registrationConfigurator.CreateRegistration(new WindsorConfigurationServiceProvider(container)); registration.ConfigureSagas(configurator); }
/// <summary> /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the StructureMap saga repository /// and the appropriate state machine saga repository under the hood. /// </summary> /// <param name="configurator"></param> /// <param name="container"></param> public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IContainer container) { var registrationConfigurator = new RegistrationConfigurator(); container.Configure(x => { if (container.TryGetInstance <ISagaStateMachineFactory>() == null) { x.AddSingleton <ISagaStateMachineFactory>(provider => new LamarSagaStateMachineFactory(provider)); } if (container.TryGetInstance <ISagaRepositoryFactory>() == null) { x.AddSingleton <ISagaRepositoryFactory>(provider => new LamarSagaRepositoryFactory(container)); } if (container.TryGetInstance <IStateMachineActivityFactory>() == null) { x.AddSingleton <IStateMachineActivityFactory>(provider => new LamarStateMachineActivityFactory()); } }); registrationConfigurator.AddSagaStateMachines(new NullSagaStateMachineRegistrar(), FindStateMachineSagaTypes(container)); var registration = registrationConfigurator.CreateRegistration(new LamarConfigurationServiceProvider(container)); registration.ConfigureSagas(configurator); }
/// <summary> /// Scans the lifetime scope and registers any state machines sagas which are found in the scope using the StructureMap saga repository /// and the appropriate state machine saga repository under the hood. /// </summary> /// <param name="configurator"></param> /// <param name="container"></param> public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, IContainer container) { var registrationConfigurator = new RegistrationConfigurator(); container.Configure(x => { if (container.TryGetInstance <ISagaStateMachineFactory>() == null) { x.For <ISagaStateMachineFactory>().Use(provider => new StructureMapSagaStateMachineFactory(container)).Singleton(); } if (container.TryGetInstance <ISagaRepositoryFactory>() == null) { x.For <ISagaRepositoryFactory>().Use(provider => new StructureMapSagaRepositoryFactory(container)).Singleton(); } if (container.TryGetInstance <IStateMachineActivityFactory>() == null) { x.For <IStateMachineActivityFactory>().Use(provider => new StructureMapStateMachineActivityFactory()).ContainerScoped(); } }); registrationConfigurator.AddSagaStateMachines(FindStateMachineSagaTypes(container)); var registration = registrationConfigurator.CreateRegistration(new StructureMapConfigurationServiceProvider(container)); registration.ConfigureSagas(configurator); }
/// <summary> /// Specify that the service bus should load the StateMachineSagas from the container passed as argument /// </summary> /// <param name="configurator"></param> /// <param name="container"></param> public static void LoadStateMachineSagas(this IReceiveEndpointConfigurator configurator, Container container) { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } if (container == null) { throw new ArgumentNullException(nameof(container)); } var registrationConfigurator = new RegistrationConfigurator(); container.RegisterInstance <ISagaStateMachineFactory>(new SimpleInjectorSagaStateMachineFactory(container)); container.RegisterInstance <IStateMachineActivityFactory>(new SimpleInjectorStateMachineActivityFactory()); container.RegisterInstance <ISagaRepositoryFactory>(new SimpleInjectorSagaRepositoryFactory(container)); IEnumerable <Type> sagaTypes = FindStateMachineSagaTypes(container); foreach (var sagaType in sagaTypes) { ((IRegistrationConfigurator)registrationConfigurator).AddSagaStateMachine(sagaType); } var registration = registrationConfigurator.CreateRegistration(new SimpleInjectorConfigurationServiceProvider(container)); registration.ConfigureSagas(configurator); }