public void SubscribeToCommand <TCommand>(CommandReceivedAsync <TCommand> commandReceived) where TCommand : class, ICommand { _engine.SubscribeToCommand <TCommand>(); _errorHandlers.AddOrUpdate(typeof(TCommand), CreateCommandErrorDelegate <TCommand>(), (key, item) => item); _messagePipelines.Add(async message => { if (message is CommandMessage <TCommand> commandMessage) { var dispatcher = new NybusDispatcher(this, commandMessage); var context = new NybusCommandContext <TCommand>(commandMessage); await commandReceived(dispatcher, context).ConfigureAwait(false); } }); }
public void SubscribeToCommand <TCommand>() where TCommand : class, ICommand { _busEngine.SubscribeToCommand((CommandReceived <TCommand>)ResolveHandlerAndHandle <ICommandHandler <TCommand>, TCommand>); }