ConfigEntry.cs 700 B

123456789101112131415161718192021222324252627282930313233
  1. namespace BepInEx.Configuration
  2. {
  3. /// <inheritdoc />
  4. public class ConfigEntry<T> : ConfigEntryBase
  5. {
  6. private T _typedValue;
  7. internal ConfigEntry(ConfigFile configFile, ConfigDefinition definition, T defaultValue) : base(configFile, definition, typeof(T), defaultValue) { }
  8. /// <summary>
  9. /// Get or set the value of the setting without boxing.
  10. /// </summary>
  11. public T TypedValue
  12. {
  13. get => _typedValue;
  14. set
  15. {
  16. value = ClampValue(value);
  17. if (Equals(_typedValue, value))
  18. return;
  19. _typedValue = value;
  20. OnSettingChanged(this);
  21. }
  22. }
  23. /// <inheritdoc />
  24. public override object Value
  25. {
  26. get => TypedValue;
  27. set => TypedValue = (T)value;
  28. }
  29. }
  30. }