// Version sans le passage par le cache public static bool?ShowDialog(Type tView, BaseNotifyPropertyChanged viewModel) { var win = GetViewInstance(tView, viewModel); var method = win.GetType().GetMethod("ShowDialog"); return((bool?)method?.Invoke(win, null)); }
private static object GetViewModelInstance(Type tViewModel, params object[] viewModelParameters) { object vm = null; // Ne pas garder en cache ces fenêtres if (_viewModelsCache.ContainsKey(tViewModel) && tViewModel != typeof(UpsertEstateViewModel) && tViewModel != typeof(UpsertTransactionViewModel) && tViewModel != typeof(UpsertPersonViewModel)) { vm = _viewModelsCache[tViewModel]; // Rafraîchir la vue mise en cache lors de la récupération BaseNotifyPropertyChanged test = (BaseNotifyPropertyChanged)vm; test.refresh(); } else { vm = Activator.CreateInstance(tViewModel, viewModelParameters); _viewModelsCache[tViewModel] = (BaseNotifyPropertyChanged)vm; } return(vm); }