Пример #1
0
        /// <summary>
        /// The difference between the value and the range limit broken, normalized according to the magnitude of the range.
        /// If the range magnitude is zero, this will return null. Otherwise always positive.
        /// </summary>
        public static double?NormalizedValueDelta(this IAttributeDefect defect)
        {
            var rangeDelta = defect.AbsoluteRangeDelta();

            if (rangeDelta == 0.0)
            {
                return(null);
            }

            return(defect.AbsoluteValueDelta() / rangeDelta);
        }
Пример #2
0
        /// <summary>
        /// The magnitude of the difference between the value and the range limit broken, 0 if value is in range.
        /// </summary>
        public static double AbsoluteValueDelta(this IAttributeDefect defect)
        {
            if (defect.TooLow())
            {
                return(defect.RangeMin - defect.Value);
            }

            if (defect.TooHigh())
            {
                return(defect.Value - defect.RangeMax);
            }

            return(0.0);
        }
Пример #3
0
 public static bool TooHigh(this IAttributeDefect defect)
 {
     return(defect.Value > defect.RangeMax);
 }
Пример #4
0
 /// <summary>
 /// The magnitude of the range, always positive.
 /// </summary>
 public static double AbsoluteRangeDelta(this IAttributeDefect defect)
 {
     return(Math.Abs(defect.RangeMax - defect.RangeMin));
 }
Пример #5
0
 public static bool TooLow(this IAttributeDefect defect)
 {
     return(defect.Value < defect.RangeMin);
 }