/// <summary> /// Determines whether the range contains another one. /// The check is performed using same rounding that will be used to store the <paramref name="metricValues"/>. /// </summary> /// <param name="metricValues">Range of metric values.</param> /// <param name="other">The metric range to check.</param> /// <param name="metricUnit"> /// The metric measurement unit that will be used to store the <paramref name="metricValues"/>. /// </param> /// <returns><c>true</c>, if the range contains another one.</returns> public static bool ContainsWithRounding( this MetricRange metricValues, MetricRange other, [NotNull] MetricUnit metricUnit) { var scaledMetricValues = metricValues.ToScaledValues(metricUnit); var scaledOtherMetricValues = other.ToScaledValues(metricUnit); var roundDigits = GetRoundingDigits(scaledMetricValues, metricUnit); scaledMetricValues = scaledMetricValues.Round(roundDigits); scaledOtherMetricValues = scaledOtherMetricValues.Round(roundDigits); return(scaledMetricValues.Contains(scaledOtherMetricValues)); }
/// <summary> /// Determines whether the range can be represented as a single point range /// (scaled and rounded min and max are the same). /// </summary> /// <param name="metricValues">Range of metric values.</param> /// <param name="metricUnit"> /// The metric measurement unit that will be used to store the <paramref name="metricValues"/>. /// </param> /// <returns><c>true</c>, if the range can be represented as a single point range.</returns> public static bool MinMaxAreSame(this MetricRange metricValues, [NotNull] MetricUnit metricUnit) { if (metricValues.IsEmpty) { return(true); } var scaledMetricValues = metricValues.ToScaledValues(metricUnit); var roundDigits = GetRoundingDigits(scaledMetricValues, metricUnit); scaledMetricValues = scaledMetricValues.Round(roundDigits); return(scaledMetricValues.Min.Equals(scaledMetricValues.Max)); }