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.

56 lines
2.1 KiB

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