private void UpdateModelState(string msg, object callback) { if (string.IsNullOrEmpty(msg)) { return; } var changeFiles = msg.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // Update local model state cache var storeFilePath = PathManager.GetModelStatesStorePath(); if (File.Exists(storeFilePath)) { var lines = File.ReadAllLines(storeFilePath).ToList(); changeFiles.ToList().ForEach(fileWithState => { var changePath = fileWithState.Substring(1); bool isNewLine = true; for (int i = 0; i < lines.Count(); i++) { if (string.IsNullOrEmpty(lines[i].Trim())) { continue; } var localPath = lines[i].Substring(1); if (localPath.Equals(changePath, StringComparison.OrdinalIgnoreCase)) { lines[i] = fileWithState; isNewLine = false; break; } } if (isNewLine) { lines.Add(fileWithState); } }); File.WriteAllLines(storeFilePath, lines.ToArray()); } else { File.WriteAllText(storeFilePath, msg); } // Sync with other editors SyncEditorActionInOtherEditorInstances(window => { if (window.CommunicateServices != null) { window.CommunicateServices.SyncModelStates(); } }); }
private void GetModelStateStore(string msg, object callback) { Utility.Log(string.Format("Editor {0} execute GetModelStateStore()", this.id)); var storeFilePath = PathManager.GetModelStatesStorePath(); if (!File.Exists(storeFilePath)) { storeFilePath = ""; } wrap = new CallbackWrapper(callback); wrap.Send(storeFilePath); }