/// <summary>
 /// Subscribes to commands of type T on the bus.
 /// </summary>
 /// <typeparam name="T">The type of commands to subscribe to.</typeparam>
 /// <param name="handler">A handler for commands of type T.</param>
 /// <exception cref="ArgumentOutOfRangeException">The class has not been given an
 /// <see cref="IDispatcher"/> on which to subscribe to commands.</exception>
 protected void Subscribe <T>(IHandleCommand <T> handler) where T : Command
 {
     if (_commandSubscriber == null)
     {
         throw new ArgumentOutOfRangeException(nameof(handler), @"TransientSubscriber not created with CommandBus to register on.");
     }
     _subscriptions.Add(_commandSubscriber.Subscribe <T>(handler));
 }
Beispiel #2
0
        public AccountCommandHandler(IRepository repo, ICommandSubscriber bus, IClock clock = null)
        {
            _repo = repo;

            _disposer = new CompositeDisposable(
                bus.Subscribe <CreateAccount>(this),
                bus.Subscribe <SetOverdraftLimit>(this),
                bus.Subscribe <SetDailyWireTransferLimit>(this),
                bus.Subscribe <DepositCheque>(this),
                bus.Subscribe <DepositCash>(this),
                bus.Subscribe <WithdrawCash>(this),
                bus.Subscribe <TryWireTransfer>(this),
                bus.Subscribe <StartNewBusinessDay>(this));
        }
 public AccountCommandHandler(IRepository repository, ICommandSubscriber dispatcher, IClock clock)
 {
     _repository = repository;
     _clock      = clock;
     _disposable = new CompositeDisposable
     {
         dispatcher.Subscribe <CreateAccount>(this),
         dispatcher.Subscribe <LimitOverdraft>(this),
         dispatcher.Subscribe <SetDailyWireTransfertLimit>(this),
         dispatcher.Subscribe <DepositCheque>(this),
         dispatcher.Subscribe <DepositCash>(this),
         dispatcher.Subscribe <WithdrawCash>(this),
         dispatcher.Subscribe <WireTransferCash>(this),
     };
 }
Beispiel #4
0
        public AccountCommandHandler(IRepository repository, ICommandSubscriber dispatcher)
        {
            _repository = repository;

            _disposable = new CompositeDisposable
            {
                dispatcher.Subscribe <CreateAccount>(this),
                dispatcher.Subscribe <ConfigureOverdraftLimit>(this),
                dispatcher.Subscribe <ConfigureDailyWireTransferLimit>(this),
                dispatcher.Subscribe <DepositCheque>(this),
                dispatcher.Subscribe <DepositCash>(this),
                dispatcher.Subscribe <WithdrawCash>(this),
                dispatcher.Subscribe <TransferWireFund>(this)
            };
        }