public UserProjectSettings FindOrAddProject(string ClientProjectFileName) { // Read the project settings UserProjectSettings CurrentProject; if (!ProjectKeyToSettings.TryGetValue(ClientProjectFileName, out CurrentProject)) { CurrentProject = new UserProjectSettings(); ProjectKeyToSettings.Add(ClientProjectFileName, CurrentProject); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(ClientProjectFileName); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); if (!Enum.TryParse(ProjectSection.GetValue("FilterType", ""), true, out CurrentProject.FilterType)) { CurrentProject.FilterType = FilterType.None; } CurrentProject.FilterBadges.UnionWith(ProjectSection.GetValues("FilterBadges", new string[0])); } return(CurrentProject); }
public UserProjectSettings FindOrAddProject(string ClientProjectFileName) { // Read the project settings UserProjectSettings CurrentProject; if (!ProjectKeyToSettings.TryGetValue(ClientProjectFileName, out CurrentProject)) { CurrentProject = new UserProjectSettings(); ProjectKeyToSettings.Add(ClientProjectFileName, CurrentProject); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(ClientProjectFileName); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); } return(CurrentProject); }
public void OpenProject(string ClientBranchPath, string ClientProjectFileName) { CloseProject(); // Update the current workspace CurrentWorkspaceKey = ClientBranchPath.Trim('/'); CurrentWorkspace = new UserWorkspaceSettings(); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if (WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if (SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if (CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if (AtIdx != -1) { int ChangeNumber; if (int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if (LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if (ColonIdx != -1) { int ChangeNumber; if (int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if (Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); foreach (string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if (int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if (DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); } // Read the project settings CurrentProjectKey = ClientProjectFileName; CurrentProject = new UserProjectSettings(); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); }