public void SaveModifiedSymbol(Symbol symbol) { RemoveObsoleteSymbolFiles(symbol); SymbolJson symbolJson = new SymbolJson(); using (var sw = new StreamWriter(GetFilePathForSymbol(symbol))) using (var writer = new JsonTextWriter(sw)) { symbolJson.Writer = writer; symbolJson.Writer.Formatting = Formatting.Indented; symbolJson.WriteSymbol(symbol); } if (!string.IsNullOrEmpty(symbol.PendingSource)) { WriteSymbolSourceToFile(symbol); } }
public virtual void SaveAll() { ResourceManager.Instance().DisableOperatorFileWatcher(); // don't update ops if file is written during save // remove all old t3 files before storing to get rid off invalid ones DirectoryInfo di = new DirectoryInfo(OperatorTypesFolder); FileInfo[] files = di.GetFiles("*" + SymbolExtension).ToArray(); foreach (FileInfo file in files) { try { File.Delete(file.FullName); } catch (Exception e) { Log.Warning("Failed to deleted file '" + file + "': " + e); } } SymbolJson symbolJson = new SymbolJson(); // store all symbols in corresponding files foreach (var(_, symbol) in SymbolRegistry.Entries) { using (var sw = new StreamWriter(OperatorTypesFolder + symbol.Name + "_" + symbol.Id + SymbolExtension)) using (var writer = new JsonTextWriter(sw)) { symbolJson.Writer = writer; symbolJson.Writer.Formatting = Formatting.Indented; symbolJson.WriteSymbol(symbol); } if (!string.IsNullOrEmpty(symbol.PendingSource)) { WriteSymbolSourceToFile(symbol); } } ResourceManager.Instance().EnableOperatorFileWatcher(); }