Passing the CQRS demo code here , the command and event handlers are connected separately, as shown below:
public interface CommandHandler<in T> { void Handle(T command); } public interface EventHandler<in T> { void Handle(T @event); } bus = BusSetup.StartWith<Conservative>() .Apply<FlexibleSubscribeAdapter>(a => { a.ByInterface(typeof(IHandleEvent<>)); a.ByInterface(typeof(IHandleCommand<>)); }) .Construct();
I use an IoC container connected to membus, and it dreams of implementing the IEnumerable<object> GetAllInstances(Type desiredType) with my container, however, unlike the demonstration using this registration method, I cannot separate the interfaces for the individual commands and events:
this.Bus = BusSetup.StartWith<Conservative>() .Apply <IoCSupport>(c => { c .SetAdapter(SimpleInjectorWiring.Instance) .SetHandlerInterface(typeof(CommandHandler<>)) ;
Can someone please tell me if there is a way around this so that we can register for an arbitrary number of types?
source share