AcceptableValueBase.cs 813 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace BepInEx.Configuration
  3. {
  4. /// <summary>
  5. /// Base type of all classes representing and enforcing acceptable values of config settings.
  6. /// </summary>
  7. public abstract class AcceptableValueBase
  8. {
  9. protected AcceptableValueBase(Type valueType)
  10. {
  11. ValueType = valueType;
  12. }
  13. /// <summary>
  14. /// Change the value to be acceptable, if it's not already.
  15. /// </summary>
  16. public abstract object Clamp(object value);
  17. /// <summary>
  18. /// Check if the value is an acceptable value.
  19. /// </summary>
  20. public abstract bool IsValid(object value);
  21. /// <summary>
  22. /// Type of the supported values.
  23. /// </summary>
  24. public Type ValueType { get; }
  25. /// <summary>
  26. /// Get the string for use in config files.
  27. /// </summary>
  28. public abstract string ToSerializedString();
  29. }
  30. }