示例#1
0
        /// <summary>
        ///     根据操作符比较值得大小
        /// </summary>
        /// <param name="operatorCompare">比较</param>
        /// <param name="baseValue">基准值</param>
        /// <param name="compareValue">比较值</param>
        public static bool CompareByOperator(OperatorCompare operatorCompare, decimal baseValue, decimal compareValue)
        {
            switch (operatorCompare)
            {
            case OperatorCompare.Equal:
                return(baseValue == compareValue);

            case OperatorCompare.Greater:
                return(compareValue > baseValue);

            case OperatorCompare.GreaterEqual:
                return(compareValue >= baseValue);

            case OperatorCompare.Less:
                return(compareValue < baseValue);

            case OperatorCompare.LessEqual:
                return(compareValue <= baseValue);

            case OperatorCompare.NotEqual:
                return(compareValue != baseValue);

            default:
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// Create a rule to validate the string length based on the property name compare operator and value to be validated.
 /// </summary>
 /// <param name="propertyName">validated property name</param>
 /// <param name="operatorCompare">Compare operator <see cref="OperatorCompare"/></param>
 /// <param name="value">Value to be compared with</param>
 public ValidateLength(string propertyName, OperatorCompare operatorCompare, int value)
     : base(propertyName, string.Format("Field {0} string length is failed the validation check", propertyName))
 {
     _operatorCompare = operatorCompare;
     _value           = value;
 }
 public ValidateValue(string propertyName, OperatorCompare operatorCompare, decimal value)
     : base(propertyName, string.Format("Значение поля {0} не соответствует заданному условию", propertyName))
 {
     _operatorCompare = operatorCompare;
     _value           = value;
 }