123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- namespace InABox.Configuration
- {
- public interface IConfiguration<T>
- {
- string[] Sections();
- T Load();
- 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();
- public abstract void Save(T obj);
- public abstract void SaveAll(Dictionary<string, T> objs);
- public abstract void Delete(Action<Exception?>? callback);
- }
- public interface IConfigurationSettings
- {
- }
- }
|