예제 #1
0
        public MainWindowViewModel(
            IGeneralBus bus,
            AccountRM accountRm,
            Guid accountId) : base(bus)
        {
            _bus       = bus;
            _accountRm = accountRm;
            _accountId = accountId;

            Output = new ReactiveList <string>()
            {
                "Initial balance: $0.00"
            };

            AddCreditOrDebitCommand = CommandBuilder.FromAction(
                canExecute: this.WhenAnyValue(x => x.Amount, x => x > 0),
                action: () =>
            {
                try
                {
                    FireCreditOrDebit();
                }
                catch (Exception e)
                {
                    //Application.Current.Dispatcher.Invoke(() => Output.Add(e.Message));
                }
            });

            _accountRm?
            .AccountUpdateMessage
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(m =>
            {
                if (m != null)
                {
                    Output.Add(m);
                }
            });
        }
예제 #2
0
        public void Run(StartupEventArgs args)
        {
            _bus = new CommandBus(
                "Main Bus",
                false,
                TimeSpan.FromMinutes(1), // TODO: Eliminate these timeouts and add the necessary timeouts to commands on a per-command basis.
                TimeSpan.FromMinutes(1));

            Configure(_bus);

            _bus.Fire(new CreateAccount(
                          Bootstrap.NewAccountId,
                          "TheAccount",
                          Guid.NewGuid(),
                          Guid.Empty));

            _accountRm = new AccountRM(NewAccountId);
            var mainWindow = new MainWindow()
            {
                ViewModel = new MainWindowViewModel(_bus, _accountRm, NewAccountId)
            };

            mainWindow.Show();
        }