public static void LoadFrom(this IReceiveEndpointConfigurator configurator, IContainer container) { var scopeProvider = new StructureMapConsumerScopeProvider(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 StructureMapSagaRepositoryFactory(container); IList <Type> sagaTypes = FindTypes <ISaga>(container, x => true); if (sagaTypes.Count > 0) { foreach (var sagaType in sagaTypes) { SagaConfiguratorCache.Configure(sagaType, configurator, sagaRepositoryFactory); } } }
/// <summary> /// Registers a consumer given the lifetime scope specified /// </summary> /// <typeparam name="T">The consumer type</typeparam> /// <param name="configurator">The service bus configurator</param> /// <param name="container">The LifetimeScope of the container</param> /// <param name="configure"></param> /// <returns></returns> public static void Consumer <T>(this IReceiveEndpointConfigurator configurator, IContainer container, Action <IConsumerConfigurator <T> > configure = null) where T : class, IConsumer { IConsumerScopeProvider scopeProvider = new StructureMapConsumerScopeProvider(container); var consumerFactory = new ScopeConsumerFactory <T>(scopeProvider); configurator.Consumer(consumerFactory, configure); }
/// <summary> /// Connect a consumer with a consumer factory method /// </summary> /// <typeparam name="TConsumer"></typeparam> /// <typeparam name="TMessage"></typeparam> /// <param name="configurator"></param> /// <param name="container"></param> /// <param name="configure"></param> /// <returns></returns> public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IContainer container, Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null) where TConsumer : class, IConsumer <Batch <TMessage> > where TMessage : class { IConsumerScopeProvider scopeProvider = new StructureMapConsumerScopeProvider(container); IConsumerFactory <TConsumer> consumerFactory = new ScopeConsumerFactory <TConsumer>(scopeProvider); configurator.Consumer(consumerFactory, configure); }