Ejemplo n.º 1
0
 public ValidationItem(ValidationField <T> field, DataValidator validator, string fieldName)
 {
     _valueMethod  = field.FieldExpression.Compile();
     _validator    = validator;
     _fieldName    = fieldName;
     _errorMessage = field.ErrorMessage;
     if (field.CompareValue is Expression <Func <T, dynamic> > )
     {
         var compareExpress = (Expression <Func <T, dynamic> >)field.CompareValue;
         _comparePropertyName = ExpressionHelper.GetExpressionText(compareExpress);
         _compareValue        = compareExpress.Compile();
     }
     else
     {
         _compareValue = field.CompareValue;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// GreaterThanOrEqual
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void GreaterThanOrEqual <T>(Expression <Func <T, dynamic> > value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.GreaterThanOrEqual, value, field);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// NotIn
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void NotIn <T>(IEnumerable <dynamic> value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.NotIn, value, field);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// GreaterThanOrEqual
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void GreaterThanOrEqual <T>(dynamic value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.GreaterThanOrEqual, value, field);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// LessThan
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void LessThan <T>(Expression <Func <T, dynamic> > value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.LessThan, value, field);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// LessThan
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void LessThan <T>(dynamic value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.LessThan, value, field);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// NotEqual
 /// </summary>
 /// <typeparam name="T">DataType</typeparam>
 /// <param name="value">value</param>
 /// <param name="field">field</param>
 public static void NotEqual <T>(dynamic value, ValidationField <T> field)
 {
     SetCompareValidation(CompareOperator.NotEqual, value, field);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Set Compare Validation
        /// </summary>
        /// <typeparam name="T">DataType</typeparam>
        /// <param name="compareOperator">compareOperator</param>
        /// <param name="value">value</param>
        /// <param name="field">field</param>
        public static void SetCompareValidation <T>(CompareOperator compareOperator, dynamic value, ValidationField <T> field)
        {
            string        validatorKey = string.Format("{0}/{1}", typeof(CompareValidator).FullName, (int)compareOperator);
            DataValidator validator    = null;

            if (_validatorList.ContainsKey(validatorKey))
            {
                validator = _validatorList[validatorKey];
            }
            else
            {
                validator = new CompareValidator(compareOperator);
                _validatorList.Add(validatorKey, validator);
            }
            field.CompareValue = value;
            SetValidation(validator, field);
        }