Пример #1
0
 /// <summary>
 /// Initializes a new instance of the EZNEW.Develop.DataValidation.ValidationItem<> class
 /// </summary>
 /// <param name="field">Field</param>
 /// <param name="validator">Data validator</param>
 /// <param name="fieldName">Field name</param>
 public ValidationItem(ValidationField <T> field, DataValidator validator, string fieldName)
 {
     valueMethod    = field.Field.Compile();
     this.validator = validator;
     this.fieldName = fieldName;
     errorMessage   = field.ErrorMessage;
     if (field.CompareValue is Expression <Func <T, dynamic> > compareExpress)
     {
         comparePropertyName = ExpressionHelper.GetExpressionText(compareExpress);
         compareValue        = compareExpress.Compile();
     }
     else
     {
         compareValue = field.CompareValue;
     }
 }
Пример #2
0
 /// <summary>
 /// Greaterthan or equal
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #3
0
 /// <summary>
 /// Not in
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #4
0
 /// <summary>
 /// Greaterthan or equal
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #5
0
 /// <summary>
 /// Lessthan
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #6
0
 /// <summary>
 /// Lessthan
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #7
0
 /// <summary>
 /// Not equal
 /// </summary>
 /// <typeparam name="T">Data type</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);
 }
Пример #8
0
        /// <summary>
        /// Set compare validation
        /// </summary>
        /// <typeparam name="T">Data type</typeparam>
        /// <param name="compareOperator">Compare operator</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;

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