public static EventFlowOptions AddCommandHandlers( this EventFlowOptions eventFlowOptions, params Type[] commandHandlerTypes) { return eventFlowOptions .AddCommandHandlers((IEnumerable<Type>) commandHandlerTypes); }
public static EventFlowOptions AddCommandHandlers( this EventFlowOptions eventFlowOptions, Assembly fromAssembly) { var commandHandlerTypes = fromAssembly .GetTypes() .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (ICommandHandler<,,>))); return eventFlowOptions .AddCommandHandlers(commandHandlerTypes); }
public static EventFlowOptions AddDefaults( this EventFlowOptions eventFlowOptions, Assembly fromAssembly) { return eventFlowOptions .AddCommandHandlers(fromAssembly) .AddMetadataProviders(fromAssembly) .AddSubscribers(fromAssembly) .AddEventUpgraders(fromAssembly); }
public static IEventFlowOptions AddCommandHandlers( this IEventFlowOptions eventFlowOptions, Assembly fromAssembly, Predicate<Type> predicate = null) { predicate = predicate ?? (t => true); var commandHandlerTypes = fromAssembly .GetTypes() .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (ICommandHandler<,,,>))) .Where(t => predicate(t)); return eventFlowOptions.AddCommandHandlers(commandHandlerTypes); }
public static void AddMessageBusHandlers(this IServiceCollection services, Assembly commandHandlerAssembly, Assembly eventListenerAssembly) { if (commandHandlerAssembly == null) { throw new ArgumentException("The command handler assembly cannot be null."); } if (eventListenerAssembly == null) { throw new ArgumentException("The event listener assembly cannot be null."); } var commandHandlers = services.AddCommandHandlers(commandHandlerAssembly); var responesCommandHandlers = services.AddResponseCommandHandlers(commandHandlerAssembly); var eventListeners = services.AddEventListeners(eventListenerAssembly); services.AddSingleton(s => new BusAutoRegistrar(s, s.GetRequiredService<IHandlerRegistrar>(), s.GetRequiredService<IHandlerRequestResponseRegistrar>(), commandHandlers, responesCommandHandlers, eventListeners)); }