Beispiel #1
0
        /// <summary>Determines if the minimum metric value should be stored.</summary>
        /// <param name="metricRange">The metric range.</param>
        /// <param name="metricUnit">The metric unit.</param>
        /// <param name="singleValueMode">The single value treatment mode.</param>
        /// <returns><c>true</c>, if the minimum metric value should be stored.</returns>
        public static bool ShouldStoreMinMetricValue(
            this MetricRange metricRange, MetricUnit metricUnit,
            MetricSingleValueMode singleValueMode)
        {
            switch (singleValueMode)
            {
            case MetricSingleValueMode.FromZeroToMax:
                return(!metricRange.Min.Equals(0));

            case MetricSingleValueMode.FromInfinityToMax:
                return(!double.IsInfinity(metricRange.Min));

            case MetricSingleValueMode.BothMinAndMax:
                return(double.IsInfinity(metricRange.Min) || !metricRange.MinMaxAreSame(metricUnit));

            default:
                throw CodeExceptions.UnexpectedArgumentValue(nameof(singleValueMode), singleValueMode);
            }
        }
Beispiel #2
0
        /// <summary>Determines if the minimum metric value should be stored.</summary>
        /// <param name="metricRange">The metric range.</param>
        /// <param name="metricUnit">The metric unit.</param>
        /// <param name="defaultMinValue">>Min value to be used by default.</param>
        /// <returns><c>true</c>, if the minimum metric value should be stored.</returns>
        public static bool ShouldStoreMinMetricValue(
            this MetricRange metricRange, MetricUnit metricUnit,
            DefaultMinMetricValue defaultMinValue)
        {
            switch (defaultMinValue)
            {
            case DefaultMinMetricValue.Zero:
                return(!metricRange.Min.Equals(0));

            case DefaultMinMetricValue.NegativeInfinity:
                return(!double.IsInfinity(metricRange.Min));

            case DefaultMinMetricValue.SameAsMax:
                return(double.IsInfinity(metricRange.Min) || !metricRange.MinMaxAreSame(metricUnit));

            default:
                throw CodeExceptions.UnexpectedArgumentValue(nameof(defaultMinValue), defaultMinValue);
            }
        }