static public string GetActiveConfigurationName(string rootPath) { ThreadHelper.ThrowIfNotOnUIThread(); string activeConfigFilename = GetActiveConfigurationFileName(rootPath); if (File.Exists(activeConfigFilename)) { var activeConfig = new FolderActiveConfiguration(); try { string jsonString = File.ReadAllText(activeConfigFilename); activeConfig = JsonConvert.DeserializeObject <FolderActiveConfiguration>(jsonString); } catch (Exception e) { OutputLog.Error(e.Message); } if (activeConfig != null) { return(activeConfig.CurrentProjectSetting); } } //try to return the first config if the active file is not present FolderSettings configs = GetConfigurations(rootPath); return(configs != null && configs.configurations.Count > 0? configs.configurations[0].name : null); }
private void DisplayError(string message) { ThreadHelper.ThrowIfNotOnUIThread(); OutputLog.Error(message); MessageWindow.Display(new MessageContent(message)); }
public void Save() { ThreadHelper.ThrowIfNotOnUIThread(); if (Filename != null && Settings != null) { try { string jsonString = JsonConvert.SerializeObject(Settings, Formatting.Indented); File.WriteAllText(Filename, jsonString); SettingsChanged?.Invoke(); } catch (Exception e) { OutputLog.Error(e.Message); } } }
private void Load() { ThreadHelper.ThrowIfNotOnUIThread(); if (Filename != null && File.Exists(Filename)) { try { string jsonString = File.ReadAllText(Filename); Settings = JsonConvert.DeserializeObject <SolutionSettings>(jsonString); SettingsChanged?.Invoke(); } catch (Exception e) { OutputLog.Error(e.Message); } } }
static private FolderSettings GetConfigurations(string rootPath) { ThreadHelper.ThrowIfNotOnUIThread(); FolderSettings settings = null; string settingsFilename = rootPath + "CMakeSettings.json"; if (File.Exists(settingsFilename)) { try { string jsonString = File.ReadAllText(settingsFilename); settings = JsonConvert.DeserializeObject <FolderSettings>(jsonString); } catch (Exception e) { OutputLog.Error(e.Message); } } return(settings); }
private void LoadSeverities(string fullPath) { ThreadHelper.ThrowIfNotOnUIThread(); UnitsCollection.Clear(); Totals.Clear(); ClearDatasets(); if (File.Exists(fullPath)) { var watch = System.Diagnostics.Stopwatch.StartNew(); FileStream fileStream = File.Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using (BinaryReader reader = new BinaryReader(fileStream)) { // Read version uint thisVersion = reader.ReadUInt32(); if (thisVersion == VERSION) { // Read Header Timeline.CompilerTimeline.Instance.TimelinePacking = reader.ReadUInt32(); // Read Units uint unitsLength = reader.ReadUInt32(); var unitList = new List <UnitValue>((int)unitsLength); for (uint i = 0; i < unitsLength; ++i) { ReadCompileUnit(reader, unitList, i); } UnitsCollection = new List <UnitValue>(unitList); //Read Datasets for (int i = 0; i < (int)CompileThresholds.Gather; ++i) { uint dataLength = reader.ReadUInt32(); var thislist = new List <CompileValue>((int)dataLength); for (uint k = 0; k < dataLength; ++k) { ReadCompileValue(reader, thislist); } Datasets[i].collection = new List <CompileValue>(thislist); } } else { OutputLog.Error("Version mismatch! Expected " + VERSION + " - Found " + thisVersion + " - Please export again with matching Data Exporter"); } } fileStream.Close(); //Post process on read data PostProcessLoadedData(); watch.Stop(); const long TicksPerMicrosecond = (TimeSpan.TicksPerMillisecond / 1000); ulong microseconds = (ulong)(watch.ElapsedTicks / TicksPerMicrosecond); OutputLog.Log("Score file processed in " + Common.UIConverters.GetTimeStr(microseconds)); } RecomputeSeverities(); ScoreDataChanged?.Invoke(); }