protected LanguageForgeProject(string projectCode, LfMergeSettings settings = null) { _settings = settings ?? MainClass.Container.Resolve<LfMergeSettings>(); _projectCode = projectCode.ToLowerInvariant(); _state = ProcessingState.Deserialize(projectCode); IsInitialClone = false; }
public ProcessingState Deserialize(string projectCode) { var fileName = Settings.GetStateFileName(projectCode); if (File.Exists(fileName)) { var json = File.ReadAllText(fileName); // TODO: Use http://stackoverflow.com/a/8312048/2314532 instead of this hack try { ProcessingState state = JsonConvert.DeserializeObject <ProcessingState>(json); if (state != null) { state.SetSettings(Settings); return(state); } } catch (JsonReaderException) { } } // If the state file is nonexistent or invalid Json, set the project back to CLONING if (!File.Exists(fileName)) { MainClass.Logger.Notice("State file doesn't exist, so setting the project back to CLONING"); } else { MainClass.Logger.Notice("State file was invalid Json, so setting the project back to CLONING"); } return(new ProcessingState(projectCode, Settings)); }
public void StartLfMerge_UnsupportedVersion_SetsErrorCode() { Assert.That(MainClass.StartLfMerge("someproject", ActionNames.None, "7000071", true), Is.EqualTo(2)); var state = ProcessingState.Deserialize("someproject"); Assert.That(state.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.ERROR)); Assert.That(state.ErrorCode, Is.EqualTo((int)ProcessingState.ErrorCodes.UnsupportedModelVersion)); Assert.That(state.ErrorMessage, Is.EqualTo("Project 'someproject' has unsupported model version '7000071'.")); }