using System.Diagnostics; using RGB.NET.Core; namespace RGB.NET.Devices.Corsair { /// /// /// Represents a Id of a on a . /// [DebuggerDisplay("{" + nameof(LedId) + "}")] public class CorsairLedId : ILedId { #region Properties & Fields internal readonly CorsairLedIds LedId; /// public IRGBDevice Device { get; } /// public bool IsValid => LedId != CorsairLedIds.Invalid; #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The the belongs to. /// The of the represented . public CorsairLedId(IRGBDevice device, CorsairLedIds ledId) { this.Device = device; this.LedId = ledId; } #endregion #region Methods /// /// Converts the Id of this to a human-readable string. /// /// A string that contains the Id of this . For example "Enter". public override string ToString() { return LedId.ToString(); } /// /// Tests whether the specified object is a and is equivalent to this . /// /// The object to test. /// true if is a equivalent to this ; otherwise, false. public override bool Equals(object obj) { CorsairLedId compareLedId = obj as CorsairLedId; if (ReferenceEquals(compareLedId, null)) return false; if (ReferenceEquals(this, compareLedId)) return true; if (GetType() != compareLedId.GetType()) return false; return compareLedId.LedId == LedId; } /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . public override int GetHashCode() { return LedId.GetHashCode(); } #endregion #region Operators /// /// Returns a value that indicates whether two specified are equal. /// /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. public static bool operator ==(CorsairLedId ledId1, CorsairLedId ledId2) { return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); } /// /// Returns a value that indicates whether two specified are equal. /// /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. public static bool operator !=(CorsairLedId ledId1, CorsairLedId ledId2) { return !(ledId1 == ledId2); } #endregion } }