/// <summary> /// Registers a view model to keep in memory. /// </summary> /// <param name="viewModel">The view model to register.</param> internal void RegisterViewModel(IAccountDataViewModel viewModel) { Arguments.NotNull(viewModel, nameof(viewModel)); viewModel.IsEditing = IsEditing; _viewModels.Add(viewModel); OnViewModelListChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Unregisters the specific view model. /// </summary> /// <param name="viewModel">The view model to unregister.</param> internal void UnregisterViewModel(IAccountDataViewModel viewModel) { Arguments.NotNull(viewModel, nameof(viewModel)); _viewModels.Remove(viewModel); viewModel.UnloadingAsync().ForgetSafely(); OnViewModelListChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Registers a view model to a list of account data to delete. /// This is used in the scenario where the user delete an account data in editing mode then /// save the changes. When this happens, we will want to iterate through these view models /// to call the <see cref="IAccountDataViewModel.DeleteAsync(System.Threading.CancellationToken)"/> method. /// </summary> /// <param name="viewModel">The view model to register.</param> internal void RegisterViewModelForDeletion(IAccountDataViewModel viewModel) { Arguments.NotNull(viewModel, nameof(viewModel)); _viewModels.Remove(viewModel); _viewModelsForDeletion.Add(viewModel); }