public static void AddMassTransitMessageBus(this IServiceCollection services, MassTransitMessageBusOptions options) { if (options == null) { throw new ArgumentException(nameof(options)); } services.AddSingleton(s => new MassTransitMessageBus(options)); services.AddSingleton<ICommandSender>(s => s.GetService<MassTransitMessageBus>()); services.AddSingleton<ICommandSenderReceiver>(s => s.GetService<MassTransitMessageBus>()); services.AddSingleton<IEventPublisher>(s => s.GetService<MassTransitMessageBus>()); services.AddSingleton<IHandlerRegistrar>(s => s.GetService<MassTransitMessageBus>()); services.AddSingleton<IHandlerRequestResponseRegistrar>(s => s.GetService<MassTransitMessageBus>()); services.AddSingleton<IFaultHandlerRegistrar>(s => s.GetService<MassTransitMessageBus>()); }
public MassTransitMessageBus(MassTransitMessageBusOptions options, HandlerManager manager, IServiceProvider services, ILoggerFactory loggerFactory) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (manager == null) { throw new ArgumentNullException(nameof(manager)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } if (loggerFactory == null) { throw new ArgumentException(nameof(loggerFactory)); } _logger = loggerFactory.CreateLogger <MassTransitMessageBus>(); _options = options; _manager = manager; _services = services; }