You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.9 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace IPA.Config
  7. {
  8. /// <summary>
  9. /// An interface for configuration providers.
  10. /// </summary>
  11. public interface IConfigProvider
  12. {
  13. /// <summary>
  14. /// Loads the data provided by this <see cref="IConfigProvider"/> into an object of type <typeparamref name="T"/>.
  15. /// </summary>
  16. /// <typeparam name="T">the type of the object to parse into</typeparam>
  17. /// <returns>the values from the config provider parsed into the object</returns>
  18. T Parse<T>();
  19. /// <summary>
  20. /// Stores the data from <paramref name="obj"/> into the <see cref="IConfigProvider"/>.
  21. /// </summary>
  22. /// <typeparam name="T">the type of <paramref name="obj"/></typeparam>
  23. /// <param name="obj">the object containing the data to save</param>
  24. void Store<T>(T obj);
  25. /// <summary>
  26. /// Gets a dynamic object providing access to the configuration.
  27. /// </summary>
  28. dynamic Dynamic { get; }
  29. #region State getters
  30. /// <summary>
  31. /// Returns <see langword="true"/> if object has changed since the last save
  32. /// </summary>
  33. bool HasChanged { get; }
  34. /// <summary>
  35. /// Will be set with the filename (no extension) to save to. When saving, the implimentation should add the appropriate extension. Should error if set multiple times.
  36. /// </summary>
  37. string Filename { set; }
  38. /// <summary>
  39. /// Gets the last time the config was modified.
  40. /// </summary>
  41. DateTime LastModified { get; }
  42. /// <summary>
  43. /// Saves configuration to file. Should error if not a root object.
  44. /// </summary>
  45. void Save();
  46. /// <summary>
  47. /// Loads the state of the file on disk.
  48. /// </summary>
  49. void Load();
  50. #endregion
  51. }
  52. }