예제 #1
0
 /// <summary>
 /// Specifies an upper limit for the value. If it is larger, it is set to the limit value
 /// while raising a warning.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="source">The source.</param>
 /// <param name="name">The name.</param>
 /// <param name="limit">The limit.</param>
 /// <returns>The limited value.</returns>
 public static int UpperLimit(this int value, object source, string name, int limit)
 {
     if (value > limit)
     {
         SpiceSharpWarning.Warning(source, Properties.Resources.Parameters_UpperLimitReached.FormatString(name, value, limit));
         value = limit;
     }
     return(value);
 }
예제 #2
0
 /// <summary>
 /// Specifies a lower limit for the value. If it is smaller, it is set to the limit value
 /// while raising a warning.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="source">The source.</param>
 /// <param name="name">The name.</param>
 /// <param name="limit">The limit.</param>
 /// <returns>The limited value.</returns>
 public static double LowerLimit(this double value, object source, string name, double limit)
 {
     if (value < limit)
     {
         SpiceSharpWarning.Warning(source, Properties.Resources.Parameters_LowerLimitReached.FormatString(name, value, limit));
         value = limit;
     }
     return(value);
 }