12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- namespace InABox.Configuration
- {
-
- public interface IConfiguration<T>
- {
- string[] Sections();
- T Load(bool useCache = true);
- Dictionary<string, T> LoadAll();
- void Save(T obj);
- /// <summary>
- /// Save all <paramref name="objs"/> to the configuration.
- /// </summary>
- /// <remarks>
- /// This does not do a complete replace; that is, it only changes the configurations with the keys of <paramref name="objs"/>,
- /// as if <see cref="Save(T)"/> was called for each element in <paramref name="objs"/>
- /// </remarks>
- /// <param name="objs"></param>
- void SaveAll(Dictionary<string, T> objs);
- void Delete(Action<Exception?>? callback = null);
- }
- public abstract class Configuration<T> : IConfiguration<T>
- {
- public Configuration(string section = "")
- {
- Section = section;
- }
- public string Section { get; }
- public abstract string[] Sections();
- public abstract Dictionary<string, T> LoadAll();
- public abstract T Load(bool useCache = true);
- public abstract void Save(T obj);
- public abstract void SaveAll(Dictionary<string, T> objs);
- public abstract void Delete(Action<Exception?>? callback);
- }
- public interface IConfigurationSettings
- {
- }
-
- public delegate T LoadSettings<T>(object sender) where T : IConfigurationSettings;
-
- public delegate void SaveSettings<T>(object sender, T properties) where T : IConfigurationSettings;
- }
|