using System;
namespace NvAPIWrapper.GPU
{
///
/// Represents an integer value range
///
public class GPUPerformanceStateValueRange : IEquatable
{
///
/// Creates a new instance of .
///
/// The lower bound of the range.
/// The upper bound of the range.
public GPUPerformanceStateValueRange(long min, long max)
{
Minimum = min;
Maximum = max;
}
///
/// Creates a new single value instance of .
///
/// The only value in the range
public GPUPerformanceStateValueRange(long value)
{
Minimum = value;
Maximum = value;
}
///
/// Gets the upper bound of the inclusive range
///
public long Maximum { get; }
///
/// Gets the lower bound of the inclusive range
///
public long Minimum { get; }
///
public bool Equals(GPUPerformanceStateValueRange other)
{
if (other == null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Maximum == other.Maximum && Minimum == other.Minimum;
}
///
/// Checks two instances of for equality.
///
/// The left side of the comparison.
/// The right side of the comparison.
/// true if instances are equal, otherwise false
public static bool operator ==(GPUPerformanceStateValueRange left, GPUPerformanceStateValueRange right)
{
return Equals(left, right) || left?.Equals(right) == true;
}
///
/// Checks two instances of for inequality.
///
/// The left side of the comparison.
/// The right side of the comparison.
/// true if instances are in-equal, otherwise false
public static bool operator !=(GPUPerformanceStateValueRange left, GPUPerformanceStateValueRange right)
{
return !(left == right);
}
///
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return Equals(obj as GPUPerformanceStateValueRange);
}
///
public override int GetHashCode()
{
unchecked
{
return ((int) Maximum * 397) ^ (int) Minimum;
}
}
///
public override string ToString()
{
if (Minimum == Maximum)
{
return $"({Minimum})";
}
return $"[({Minimum}) - ({Maximum})]";
}
}
}