using System; namespace BepInEx.Configuration { /// /// Section and key of a setting. Used as a unique key for identification within a . /// The same definition can be used in multiple config files, it will point to different settings then. /// /// public class ConfigDefinition : IEquatable { /// /// Group of the setting. All settings within a config file are grouped by this. /// public string Section { get; } /// /// Name of the setting. /// public string Key { get; } /// /// Create a new definition. Definitions with same section and key are equal. /// /// Group of the setting, case sensitive. /// Name of the setting, case sensitive. public ConfigDefinition(string section, string key) { Key = key ?? throw new ArgumentNullException(nameof(key)); Section = section ?? throw new ArgumentNullException(nameof(section)); } /// [Obsolete("description argument is no longer used, put it in a ConfigDescription instead")] public ConfigDefinition(string section, string key, string description) : this(section, key) { } /// /// Check if the definitions are the same. /// /// public bool Equals(ConfigDefinition other) { if (other == null) return false; return string.Equals(Key, other.Key) && string.Equals(Section, other.Section); } /// /// Check if the definitions are the same. /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return Equals(obj as ConfigDefinition); } /// public override int GetHashCode() { unchecked { int hashCode = Key != null ? Key.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Section != null ? Section.GetHashCode() : 0); return hashCode; } } /// /// Check if the definitions are the same. /// public static bool operator ==(ConfigDefinition left, ConfigDefinition right) => Equals(left, right); /// /// Check if the definitions are the same. /// public static bool operator !=(ConfigDefinition left, ConfigDefinition right) => !Equals(left, right); /// public override string ToString() { return Section + "." + Key; } } }