AcceptableValueBase.cs 894 B

123456789101112131415161718192021222324252627282930313233343536
  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. /// <param name="valueType">Type of values that this class can Clamp.</param>
  10. protected AcceptableValueBase(Type valueType)
  11. {
  12. ValueType = valueType;
  13. }
  14. /// <summary>
  15. /// Change the value to be acceptable, if it's not already.
  16. /// </summary>
  17. public abstract object Clamp(object value);
  18. /// <summary>
  19. /// Check if the value is an acceptable value.
  20. /// </summary>
  21. public abstract bool IsValid(object value);
  22. /// <summary>
  23. /// Type of the supported values.
  24. /// </summary>
  25. public Type ValueType { get; }
  26. /// <summary>
  27. /// Get the string for use in config files.
  28. /// </summary>
  29. public abstract string ToDescriptionString();
  30. }
  31. }