ConfigDefinition.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. namespace BepInEx.Configuration
  2. {
  3. public class ConfigDefinition
  4. {
  5. public string Section { get; }
  6. public string Key { get; }
  7. public string Description { get; internal set; }
  8. public ConfigDefinition(string section, string key, string description = null)
  9. {
  10. Key = key;
  11. Section = section;
  12. Description = description;
  13. }
  14. public override bool Equals(object obj)
  15. {
  16. if (ReferenceEquals(null, obj))
  17. return false;
  18. if (ReferenceEquals(this, obj))
  19. return true;
  20. if (obj.GetType() != this.GetType())
  21. return false;
  22. if (!(obj is ConfigDefinition other))
  23. return false;
  24. return string.Equals(Key, other.Key)
  25. && string.Equals(Section, other.Section);
  26. }
  27. public override int GetHashCode()
  28. {
  29. unchecked
  30. {
  31. int hashCode = Key != null ? Key.GetHashCode() : 0;
  32. hashCode = (hashCode * 397) ^ (Section != null ? Section.GetHashCode() : 0);
  33. return hashCode;
  34. }
  35. }
  36. public static bool operator ==(ConfigDefinition left, ConfigDefinition right)
  37. => Equals(left, right);
  38. public static bool operator !=(ConfigDefinition left, ConfigDefinition right)
  39. => !Equals(left, right);
  40. }
  41. }