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.

63 lines
2.5 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. #if NET4
  23. /// <summary>
  24. /// Gets a dynamic object providing access to the configuration.
  25. /// </summary>
  26. /// <value>a dynamically bound object to use to access config values directly</value>
  27. dynamic Dynamic { get; }
  28. #endif
  29. #region State getters
  30. /// <summary>
  31. /// Returns <see langword="true"/> if object has changed since the last save
  32. /// </summary>
  33. /// <value><see langword="true"/> if object has changed since the last save, else <see langword="false"/></value>
  34. bool HasChanged { get; }
  35. /// <summary>
  36. /// Returns <see langword="true"/> if the data in memory has been changed - notably including loads.
  37. /// </summary>
  38. /// <value><see langword="true"/> if the data in memory has been changed, else <see langword="false"/></value>
  39. bool InMemoryChanged { get; set; }
  40. /// <summary>
  41. /// 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.
  42. /// </summary>
  43. /// <value>the extensionless filename to save to</value>
  44. string Filename { set; }
  45. /// <summary>
  46. /// Gets the last time the config was modified.
  47. /// </summary>
  48. /// <value>the last time the config file was modified</value>
  49. DateTime LastModified { get; }
  50. /// <summary>
  51. /// Saves configuration to file. Should error if not a root object.
  52. /// </summary>
  53. void Save();
  54. /// <summary>
  55. /// Loads the state of the file on disk.
  56. /// </summary>
  57. void Load();
  58. #endregion
  59. }
  60. }