Example #1
0
        public void UnregisterViewModelInstance_ExistingViewModel()
        {
            var manager   = new ViewModelManager();
            var viewModel = new InterestingViewModel();

            manager.RegisterViewModelInstance(viewModel);
            manager.UnregisterViewModelInstance(viewModel);
        }
Example #2
0
        /// <summary>
        /// Closes this instance. Always called after the <see cref="M:Catel.MVVM.IViewModel.CancelViewModel"/> of <see cref="M:Catel.MVVM.IViewModel.SaveViewModel"/> method.
        /// </summary>
        /// <param name="result">The result to pass to the view. This will, for example, be used as <c>DialogResult</c>.</param>
        void MVVM.IViewModel.CloseViewModel(bool?result)
        {
            if (IsClosed)
            {
                return;
            }

            _catelClosing.SafeInvoke(this);

            IsClosed = true;

            ViewModelManager.UnregisterViewModelInstance(this);

            _catelClosed.SafeInvoke(this, new ViewModelClosedEventArgs(this, result));
        }
Example #3
0
        /// <summary>
        /// Closes this instance. Always called after the <see cref="M:Catel.MVVM.IViewModel.CancelViewModel"/> of <see cref="M:Catel.MVVM.IViewModel.SaveViewModel"/> method.
        /// </summary>
        /// <param name="result">The result to pass to the view. This will, for example, be used as <c>DialogResult</c>.</param>
        Task MVVM.IViewModel.CloseViewModel(bool?result)
        {
            return(Task.Factory.StartNew(() =>
            {
                if (IsClosed)
                {
                    return;
                }

                _catelClosing.SafeInvoke(this);

                IsClosed = true;

                ViewModelManager.UnregisterViewModelInstance(this);

                _catelClosed.SafeInvoke(this, new ViewModelClosedEventArgs(this, result));
            }));
        }
Example #4
0
        public void UnregisterViewModelInstance_NotExistingViewModel()
        {
            var manager = new ViewModelManager();

            manager.UnregisterViewModelInstance(new InterestingViewModel());
        }
Example #5
0
        public void UnregisterViewModelInstance_Null()
        {
            var manager = new ViewModelManager();

            ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => manager.UnregisterViewModelInstance(null));
        }
 public void UnregisterViewModelInstance_NotExistingViewModel()
 {
     var manager = new ViewModelManager();
     manager.UnregisterViewModelInstance(new InterestingViewModel());
 }
        public void UnregisterViewModelInstance_ExistingViewModel()
        {
            var manager = new ViewModelManager();
            var viewModel = new InterestingViewModel();

            manager.RegisterViewModelInstance(viewModel);
            manager.UnregisterViewModelInstance(viewModel);
        }
        public void UnregisterViewModelInstance_Null()
        {
            var manager = new ViewModelManager();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => manager.UnregisterViewModelInstance(null));
        }