/// <summary> /// Initializes a new instance of the <see cref="NavigationService"/> class. /// </summary> /// <param name="statePersistor"> The state persistor. </param> /// <param name="viewModelLocator"> The ViewModel instance locator. </param> /// <param name="viewLocator"> The ViewLocator</param> /// <param name="platformNavigator"> The platform navigator. </param> public NavigationService( IViewLocator viewLocator, IViewModelLocator viewModelLocator, IStatePersistor statePersistor, IPlatformNavigator platformNavigator) { this.viewModelLocator = viewModelLocator; this.viewLocator = viewLocator; this.statePersistor = statePersistor; this.platformNavigator = platformNavigator; this.platformNavigator.BackNavigationRequested += this.PlatformBackNavigationRequested; }
public override bool Execute() { try { if (StatePersistor == null) { StatePersistor = new StatePersistor(StateFilePath); } // If build is a success, then clean the state if (BuildStatus == "Success") { StatePersistor.CleanState(); Trace.WriteLine("**State cleaned"); return true; } // There is a break that happened before, set the original breaker details if (BuildStatus == "Failure" && StatePersistor.ContainsBreak) { BreakerDisplayName = StatePersistor.BreakerDisplayName; BreakerMailAddress = StatePersistor.BreakerEmailAddress; BreakTimeStamp = StatePersistor.BreakDate; return true; } // If there is no state, then it means that this break is the first, // persist it in the state and set breaker details to the requestor. if (BuildStatus == "Failure" && !StatePersistor.ContainsBreak) { string stateTemp = String.Format("{0};{1};{2};{3}", DateProvider.GetTimeStamp().ToString(DateFormat), RequestorDisplayName, RequestorMailAddress, BuildStatus); Trace.WriteLine("**Writing keeper state:" + stateTemp); StatePersistor.WriteState(stateTemp); BreakerDisplayName = RequestorDisplayName; BreakerMailAddress = RequestorMailAddress; BreakTimeStamp = DateTime.Now.ToString(DateFormat); } return true; } catch (Exception ex) { Log.LogErrorFromException(ex, true); return false; } }