ConfigDefinition.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. namespace BepInEx.Configuration
  3. {
  4. public class ConfigDefinition : IEquatable<ConfigDefinition>
  5. {
  6. public string Section { get; }
  7. public string Key { get; }
  8. public ConfigDefinition(string section, string key)
  9. {
  10. Key = key;
  11. Section = section;
  12. }
  13. public bool Equals(ConfigDefinition other)
  14. {
  15. if (other == null) return false;
  16. return string.Equals(Key, other.Key)
  17. && string.Equals(Section, other.Section);
  18. }
  19. public override bool Equals(object obj)
  20. {
  21. if (ReferenceEquals(null, obj))
  22. return false;
  23. if (ReferenceEquals(this, obj))
  24. return true;
  25. return Equals(obj as ConfigDefinition);
  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. public override string ToString()
  41. {
  42. return Section + " / " + Key;
  43. }
  44. }
  45. }