using System; using System.Runtime.InteropServices; namespace WindowsDisplayAPI.Native.Structures { /// /// Locally unique identifier is a 64-bit value guaranteed to be unique only on the system on which it was generated. /// [StructLayout(LayoutKind.Sequential)] public struct LUID : IEquatable { /// /// 32Bit unsigned integer, low /// public readonly uint LowPart; /// /// 32Bit signed integer, high /// public readonly int HighPart; /// /// Creates a new LUID /// /// 32Bit unsigned integer, low /// 32Bit signed integer, high public LUID(uint lowPart, int highPart) { LowPart = lowPart; HighPart = highPart; } /// public override string ToString() { return $"{{ {LowPart:X} - {HighPart:X} }}"; } /// public bool Equals(LUID other) { return LowPart == other.LowPart && HighPart == other.HighPart; } /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return false; } return obj is LUID luid && Equals(luid); } /// /// Checks for equality between two objects of same type /// /// The first object /// The second object /// true, if both objects are equal, otherwise false public static bool operator ==(LUID left, LUID right) { return Equals(left, right) || left.Equals(right); } /// /// Checks for inequality between two objects of same type /// /// The first object /// The second object /// true, if both objects are not equal, otherwise false public static bool operator !=(LUID left, LUID right) { return !(left == right); } /// public override int GetHashCode() { unchecked { return ((int) LowPart * 397) ^ HighPart; } } /// /// Checks if this type is empty and holds no real data /// /// true if empty, otherwise false public bool IsEmpty() { return LowPart == 0 && HighPart == 0; } /// /// Returns an empty instance of this type /// public static LUID Empty { get => default; } } }