public virtual IMvxViewModel Reload(IMvxViewModel viewModel, IMvxBundle parameterValues, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) { RunViewModelLifecycle(viewModel, parameterValues, savedState, navigationArgs); return(viewModel); }
public virtual IMvxViewModel Load(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) { IMvxViewModel viewModel; try { viewModel = (IMvxViewModel)Mvx.IoCProvider.IoCConstruct(viewModelType); } catch (Exception exception) { throw exception.MvxWrap("Problem creating viewModel of type {0}", viewModelType.Name); } RunViewModelLifecycle(viewModel, parameterValues, savedState, navigationArgs); return(viewModel); }
protected void RunViewModelLifecycle <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, IMvxBundle parameterValues, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) { try { CallCustomInitMethods(viewModel, parameterValues); if (navigationArgs?.Cancel == true) { return; } if (savedState != null) { CallReloadStateMethods(viewModel, savedState); if (navigationArgs?.Cancel == true) { return; } } viewModel.Start(); if (navigationArgs?.Cancel == true) { return; } viewModel.Prepare(); if (navigationArgs?.Cancel == true) { return; } viewModel.Prepare(param); if (navigationArgs?.Cancel == true) { return; } } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
public override IMvxViewModel Load(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) { // CALENDARIO if (viewModelType == typeof(CalendarioViewModel)) { if (App.CalendarioVM == null) { App.CalendarioVM = (CalendarioViewModel)base.Load(viewModelType, parameterValues, savedState, navigationArgs); } return(App.CalendarioVM); } // OTROS VIEW MODELS return(base.Load(viewModelType, parameterValues, savedState, navigationArgs)); }
public IMvxViewModel LoadViewModel <TParameter>(MvxViewModelRequest request, TParameter param, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) where TParameter : notnull { if (request.ViewModelType == typeof(MvxNullViewModel)) { return(new MvxNullViewModel()); } var viewModelLocator = FindViewModelLocator(request); IMvxViewModel <TParameter> viewModel = null; var parameterValues = new MvxBundle(request.ParameterValues); try { viewModel = viewModelLocator.Load(request.ViewModelType, param, parameterValues, savedState, navigationArgs); } catch (Exception exception) { throw exception.MvxWrap( "Failed to construct and initialize ViewModel for type {0} from locator {1} - check InnerException for more information", request.ViewModelType, viewModelLocator.GetType().Name); } return(viewModel); }
public IMvxViewModel ReloadViewModel <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, MvxViewModelRequest request, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs) where TParameter : notnull { var viewModelLocator = FindViewModelLocator(request); var parameterValues = new MvxBundle(request.ParameterValues); try { viewModel = viewModelLocator.Reload(viewModel, param, parameterValues, savedState, navigationArgs); } catch (Exception exception) { throw exception.MvxWrap( "Failed to reload a previously created created ViewModel for type {0} from locator {1} - check InnerException for more information", request.ViewModelType, viewModelLocator.GetType().Name); } return(viewModel); }