예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="MetricInfoAttribute"/> class.</summary>
        /// <param name="category">The category of the metric.</param>
        /// <param name="singleValueMode">The single value treatment mode.</param>
        public MetricInfoAttribute([NotNull] string category, MetricSingleValueMode singleValueMode)
        {
            Code.NotNullNorEmpty(category, nameof(category));

            Category        = category;
            SingleValueMode = singleValueMode;
        }
예제 #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="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);
            }
        }
예제 #3
0
        /// <summary>Returns minimum metric value.</summary>
        /// <param name="metricMaxValue">The maximum metric value.</param>
        /// <param name="singleValueMode">The single value treatment mode.</param>
        /// <returns>Minimum metric value.</returns>
        private static double GetMinMetricValue(
            this double metricMaxValue,
            MetricSingleValueMode singleValueMode)
        {
            if (metricMaxValue.Equals(0))
            {
                return(0);
            }
            switch (singleValueMode)
            {
            case MetricSingleValueMode.FromZeroToMax:
                return(0);

            case MetricSingleValueMode.FromInfinityToMax:
                return(double.NegativeInfinity);

            case MetricSingleValueMode.BothMinAndMax:
                return(double.IsInfinity(metricMaxValue) ? double.NegativeInfinity : metricMaxValue);

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