public static void RemoveSections(TrinityStorage storages, IEnumerable <SettingsSelectionItem> sections) { if (sections != null) { foreach (var section in sections) { ClearSection(storages, section); } } }
private static void ClearSection(TrinityStorage storages, SettingsSelectionItem sectionDefinition) { switch (sectionDefinition.Section) { case SettingsSection.Dynamic: var foundItem = storages.Dynamic?.Settings.FirstOrDefault(s => s.Name == sectionDefinition.SectionName); if (foundItem != null) { storages.Dynamic.Settings.Remove(foundItem); } break; } }
/// <summary> /// Look through a TrinitySetting object and return a list of the sections that are populated with data. /// </summary> public static HashSet <SettingsSelectionItem> GetSections(TrinityStorage storages) { var result = new HashSet <SettingsSelectionItem>(); if (storages.Dynamic?.Settings != null) { foreach (var item in storages.Dynamic.Settings) { result.Add(new SettingsSelectionItem(SettingsSection.Dynamic, item.Name)); } } Core.Logger.Log($"File contains {result.Count} sections: {string.Join(", ", result)}"); return(result); }
/// <summary> /// Clear the specified parts of a TrinitySetting object so that they have no data. /// </summary> public static void UpdateSections(string actionDescripter, TrinityStorage storages, SettingsSelectionViewModel selectionsViewModel) { foreach (var sectionEntry in selectionsViewModel.Selections) { if (sectionEntry.IsSelected) { if (!string.IsNullOrEmpty(actionDescripter)) { Core.Logger.Log($"{actionDescripter} Section: {sectionEntry}"); } continue; } ClearSection(storages, sectionEntry); } }
public static void InitializeSettings() { Storage = new TrinityStorage(); Storage.Load(); ChangeEvents.HeroId.Changed += HeroIdOnChanged; }