using System;
using System.Runtime.InteropServices;
namespace NvAPIWrapper.Native.Display.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, Pack = 8)]
public struct LUID : IEquatable
{
///
/// 32Bit unsigned integer, low
///
public readonly uint LowPart;
///
/// 32Bit signed integer, high
///
public readonly int 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 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.Equals(right);
}
///
public override int GetHashCode()
{
unchecked
{
return ((int) LowPart * 397) ^ HighPart;
}
}
}
}