Ejemplo n.º 1
0
 public static void RemoveSections(TrinityStorage storages, IEnumerable <SettingsSelectionItem> sections)
 {
     if (sections != null)
     {
         foreach (var section in sections)
         {
             ClearSection(storages, section);
         }
     }
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }
Ejemplo n.º 5
0
 public static void InitializeSettings()
 {
     Storage = new TrinityStorage();
     Storage.Load();
     ChangeEvents.HeroId.Changed += HeroIdOnChanged;
 }