ISettingsRepository.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. namespace UnityEditor.SettingsManagement
  2. {
  3. /// <summary>
  4. /// A settings repository is responsible for implementing the saving and loading of values.
  5. /// </summary>
  6. public interface ISettingsRepository
  7. {
  8. /// <value>
  9. /// What SettingsScope this repository applies to.
  10. /// </value>
  11. SettingsScope scope { get; }
  12. /// <summary>
  13. /// A name to identify this repository.
  14. /// </summary>
  15. string name { get; }
  16. /// <value>
  17. /// File path to the serialized settings data.
  18. /// </value>
  19. string path { get; }
  20. /// <summary>
  21. /// Save all settings to their serialized state.
  22. /// </summary>
  23. void Save();
  24. /// <summary>
  25. /// Set a value for key of type T.
  26. /// </summary>
  27. /// <param name="key">The settings key.</param>
  28. /// <param name="value">The value to set. Must be serializable.</param>
  29. /// <typeparam name="T">Type of value.</typeparam>
  30. void Set<T>(string key, T value);
  31. /// <summary>
  32. /// Get a value with key of type T, or return the fallback value if no matching key is found.
  33. /// </summary>
  34. /// <param name="key">The settings key.</param>
  35. /// <param name="fallback">If no key with a value of type T is found, this value is returned.</param>
  36. /// <typeparam name="T">Type of value to search for.</typeparam>
  37. T Get<T>(string key, T fallback = default(T));
  38. /// <summary>
  39. /// Does the repository contain a setting with key and type.
  40. /// </summary>
  41. /// <param name="key">The settings key.</param>
  42. /// <typeparam name="T">The type of value to search for.</typeparam>
  43. /// <returns>True if a setting matching both key and type is found, false if no entry is found.</returns>
  44. bool ContainsKey<T>(string key);
  45. /// <summary>
  46. /// Remove a key value pair from the settings repository.
  47. /// </summary>
  48. /// <param name="key"></param>
  49. /// <typeparam name="T"></typeparam>
  50. void Remove<T>(string key);
  51. }
  52. }