Beispiel #1
0
        public void when_Close_is_called_then_Closing_is_called_then_Closed()
        {
            var closingStrategy = new ClosingStrategy(new NoOpLogger());

            var closingCalled = false;
            var closedCalled = false;

            closingStrategy.Closing
                           .Subscribe(_ =>
                                      {
                                          Assert.That(closingCalled, Is.False);
                                          Assert.That(closedCalled, Is.False);

                                          closingCalled = true;
                                      });

            closingStrategy.Closing
                           .Subscribe(_ =>
                           {
                               Assert.That(closingCalled, Is.True);
                               Assert.That(closedCalled, Is.False);

                               closedCalled = true;
                           });

            closingStrategy.Close();

            Assert.That(closingCalled, Is.True);
            Assert.That(closedCalled, Is.True);
        }
Beispiel #2
0
        protected Workspace(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog)
        {
            _log = log;
            _scheduler = scheduler;
            _standardDialog = standardDialog;

            ClosingStrategy = new ClosingStrategy(log);
            ClosingStrategy.AddDisposable(Disposables);

            ClosingStrategy.Closing
                           .TakeUntil(ClosingStrategy.Closed)
                           .Subscribe(_ =>
                                      {
                                          Closing();

                                          CleanUp();
                                      });

            this.ExecuteOnClosed(() => Disposables.Dispose());

            BusyViewModel = new BusyViewModel(scheduler);
            BusyViewModel.AddDisposable(Disposables);

            ActivationStateViewModel = new ActivationStateViewModel(log, scheduler);
            ActivationStateViewModel.AddDisposable(Disposables);

            ActivationStateViewModel.OnInitialise
                                    .SelectMany(_ => OnInitialise().ToObservable()
                                                                   .TakeUntil(BusyViewModel.BusyLatch))
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => { });

            ActivationStateViewModel.ActivationStateChanged
                                    .ObserveOn(scheduler.Dispatcher.RX)
                                    .Where(isActive => isActive)
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => OnActivate());

            ActivationStateViewModel.ActivationStateChanged
                                    .ObserveOn(scheduler.Dispatcher.RX)
                                    .Where(isActive => !isActive)
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => OnDeActivate());

            Show();
        }
Beispiel #3
0
 public SupportClosing()
 {
     ClosingStrategy = new ClosingStrategy(new NoOpLogger());
 }