using System; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Interfaces; namespace NvAPIWrapper.Native.DRS.Structures { /// /// DRSSessionHandle is a reference to a DRS session. /// [StructLayout(LayoutKind.Sequential)] public struct DRSSessionHandle : IHandle, IEquatable { internal readonly IntPtr _MemoryAddress; /// public bool Equals(DRSSessionHandle other) { return _MemoryAddress.Equals(other._MemoryAddress); } /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return false; } return obj is DRSSessionHandle handle && Equals(handle); } /// public override int GetHashCode() { return _MemoryAddress.GetHashCode(); } /// public override string ToString() { return $"DRSSessionHandle #{MemoryAddress.ToInt64()}"; } /// public IntPtr MemoryAddress { get => _MemoryAddress; } /// public bool IsNull { get => _MemoryAddress == IntPtr.Zero; } /// /// 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 ==(DRSSessionHandle left, DRSSessionHandle 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 !=(DRSSessionHandle left, DRSSessionHandle right) { return !left.Equals(right); } /// /// Gets default DRSSessionHandle with a null pointer /// public static DRSSessionHandle DefaultHandle { get => default(DRSSessionHandle); } } }