/// <summary> /// Reset a value within the file to the default data provided when it was created. /// </summary> // Todo: make a version of this with nested paths public void ResetValueToDefault(string key) { if (!DefaultFileCache.KeyExists(key)) { this.DeleteKey(key); return; } var defaultNode = DefaultFileCache.TopLevelNodes[key]; string defaultValueSucc = DataConverter.GetLineTextIncludingChildLines(defaultNode); string fileText; if (this.KeyExists(key)) { var node = TopLevelNodes[key]; node.ClearChildren(); string previousLineTarget = node.RawText; var lines = this.GetRawLines().ToList(); int index = lines.IndexOf(previousLineTarget); lines[index] = defaultValueSucc; fileText = String.Join(Utilities.NewLine, lines); } else { fileText = this.GetRawText(); fileText += Utilities.NewLine; fileText += defaultValueSucc; } this.SetSavedText(fileText); this.ReloadAllData(); }
/// <summary> /// Reset the file to the default data provided when it was created. /// </summary> public void ResetToDefaultData() { SetSavedText(DefaultFileCache?.GetRawText() ?? string.Empty); ReloadAllData(); }