using System; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Helpers; using NvAPIWrapper.Native.Helpers.Structures; using NvAPIWrapper.Native.Interfaces; using NvAPIWrapper.Native.Interfaces.Display; // ReSharper disable RedundantExtendsListEntry namespace NvAPIWrapper.Native.Display.Structures { /// /// Holds information about a path's target /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct PathTargetInfoV1 : IPathTargetInfo, IInitializable, IDisposable, IAllocatable, IEquatable, IEquatable { internal readonly uint _DisplayId; internal ValueTypeReference _Details; /// public override string ToString() { return $"PathTargetInfoV2: Display #{_DisplayId}"; } /// public uint DisplayId { get => _DisplayId; } /// public bool Equals(PathTargetInfoV1 other) { return _DisplayId == other._DisplayId && _Details.Equals(other._Details); } /// public bool Equals(PathTargetInfoV2 other) { return _DisplayId == other._DisplayId && _Details.Equals(other._Details); } /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return false; } return obj is PathTargetInfoV1 && Equals((PathTargetInfoV1) obj); } /// public override int GetHashCode() { unchecked { // ReSharper disable once NonReadonlyMemberInGetHashCode return ((int) _DisplayId * 397) ^ _Details.GetHashCode(); } } /// public PathAdvancedTargetInfo? Details { get => _Details.ToValueType() ?? default(PathAdvancedTargetInfo); } /// /// Creates a new PathTargetInfoV1 /// /// Display Id public PathTargetInfoV1(uint displayId) : this() { _DisplayId = displayId; } /// /// Creates a new PathTargetInfoV1 /// /// Display Id /// Extra information public PathTargetInfoV1(uint displayId, PathAdvancedTargetInfo details) : this(displayId) { _Details = ValueTypeReference.FromValueType(details); } /// public void Dispose() { _Details.Dispose(); } void IAllocatable.Allocate() { if (_Details.IsNull) { var detail = typeof(PathAdvancedTargetInfo).Instantiate(); _Details = ValueTypeReference.FromValueType(detail); } } } }