protected void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle parameterValues = null, IMvxBundle savedState = null) { try { CallCustomInitMethods(viewModel, parameterValues); if (savedState != null) { CallReloadStateMethods(viewModel, savedState); } viewModel.Start(); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
protected void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle parameterValues, IMvxBundle savedState) { try { CallCustomInitMethods(viewModel, parameterValues); if (savedState != null) { CallReloadStateMethods(viewModel, savedState); } viewModel.Start(); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
protected void RunViewModelLifecycle( IMvxViewModel viewModel, IMvxBundle?parameterValues, IMvxBundle?savedState, IMvxNavigateEventArgs?navigationArgs) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } 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.InitializeTask = MvxNotifyTask.Create(() => viewModel.Initialize()); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
private static void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle savedState, MvxViewModelRequest request) { try { var parameterValues = new MvxBundle(request.ParameterValues); viewModel.CallBundleMethods("Init", parameterValues); if (savedState != null) { viewModel.CallBundleMethods("ReloadState", savedState); } viewModel.Start(); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
private UIViewController CreateTabFor(int index, string title, string imageName, IMvxViewModel viewModel) { var controller = new UINavigationController(); var viewController = this.CreateViewControllerFor(viewModel) as UIViewController; viewModel.Start(); //var request = new MvxViewModelRequest ( viewModelType, null, null ); //var viewModel = Mvx.Resolve<IMvxViewModelLoader> ().LoadViewModel ( request, null ); //var screen = this.CreateViewControllerFor ( viewModel ) as MvxViewController; controller.PushViewController(viewController, true); controller.TabBarItem = new UITabBarItem(title, UIImage.FromBundle(imageName), index); SetNavigationBarFor(controller); return(controller); }
private UIViewController CreateTabFor(string title, string imageName, IMvxViewModel viewModel) { UIViewController screen; if (viewModel.GetType() == typeof(SettingsViewModel)) { screen = new SettingsPage().CreateViewController(); } else { screen = this.CreateViewControllerFor(viewModel) as UIViewController; viewModel.Start(); } SetTitleAndTabBarItem(screen, title, imageName); return(screen); }
protected void RunViewModelLifecycle <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, IMvxBundle parameterValues, IMvxBundle savedState) { try { CallCustomInitMethods(viewModel, parameterValues); if (savedState != null) { CallReloadStateMethods(viewModel, savedState); } viewModel.Start(); viewModel.Prepare(); viewModel.Prepare(param); viewModel.InitializeTask = MvxNotifyTask.Create(() => viewModel.Initialize()); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }
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 virtual bool TryLoad(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, out IMvxViewModel viewModel) { viewModel = null; try { viewModel = (IMvxViewModel)Mvx.IocConstruct(viewModelType); } catch (Exception exception) { MvxTrace.Warning("Problem creating viewModel of type {0} - problem {1}", viewModelType.Name, exception.ToLongString()); return(false); } try { CallCustomInitMethods(viewModel, parameterValues); if (savedState != null) { CallReloadStateMethods(viewModel, savedState); } viewModel.Start(); } catch (Exception exception) { MvxTrace.Warning("Problem initialising viewModel of type {0} - problem {1}", viewModelType.Name, exception.ToLongString()); return(false); } return(true); }
public virtual bool TryLoad(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, out IMvxViewModel viewModel) { viewModel = null; try { viewModel = (IMvxViewModel) Mvx.IocConstruct(viewModelType); } catch (Exception exception) { MvxTrace.Warning("Problem creating viewModel of type {0} - problem {1}", viewModelType.Name, exception.ToLongString()); return false; } try { CallCustomInitMethods(viewModel, parameterValues); if (savedState != null) { CallReloadStateMethods(viewModel, savedState); } viewModel.Start(); } catch (Exception exception) { MvxTrace.Warning("Problem initialising viewModel of type {0} - problem {1}", viewModelType.Name, exception.ToLongString()); return false; } return true; }
private static void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle savedState, MvxViewModelRequest request) { try { if (request != null) { var parameterValues = new MvxBundle(request.ParameterValues); viewModel.CallBundleMethods("Init", parameterValues); } if (savedState != null) { viewModel.CallBundleMethods("ReloadState", savedState); } viewModel.Start(); } catch (Exception exception) { throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name); } }