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.

49 lines
1.8 KiB

  1. using System;
  2. using System.IO;
  3. using IPA.Config.Data;
  4. namespace IPA.Config
  5. {
  6. /// <summary>
  7. /// An interface for configuration providers.
  8. /// </summary>
  9. /// <remarks>
  10. /// Implementers must provide a default constructor. Do not assume that <see cref="File"/> will ever be set for a given object.
  11. /// </remarks>
  12. public interface IConfigProvider
  13. {
  14. /// <summary>
  15. /// Gets the extension <i>without</i> a dot to use for files handled by this provider.
  16. /// </summary>
  17. /// <remarks>
  18. /// This must work immediately, and is used to generate the <see cref="FileInfo"/> used to set
  19. /// <see cref="File"/>.
  20. /// </remarks>
  21. string Extension { get; }
  22. /// <summary>
  23. /// Sets the file that this provider will read and write to.
  24. /// </summary>
  25. /// <remarks>
  26. /// The provider is expected to gracefully handle this changing at any point,
  27. /// and is expected to close any old file handles when this is reassigned.
  28. /// This may be set to the same file multiple times in this object's lifetime.
  29. /// This will always have been set at least once before any calls to <see cref="Load"/>
  30. /// or <see cref="Store"/> are made.
  31. /// </remarks>
  32. FileInfo File { set; }
  33. /// <summary>
  34. /// Stores the <see cref="Value"/> given to disk in the format specified.
  35. /// </summary>
  36. /// <param name="value">the <see cref="Value"/> to store</param>
  37. void Store(Value value);
  38. /// <summary>
  39. /// Loads a <see cref="Value"/> from disk in whatever format this provider provides
  40. /// and returns it.
  41. /// </summary>
  42. /// <returns>the <see cref="Value"/> loaded</returns>
  43. Value Load();
  44. }
  45. }