/// <summary> /// Add new validation rule for control. /// </summary> internal void AddValidationSet(ValidationSet validationSet) { CheckThread(); // check if corresponding control already has validation rule var rule = rules.Where(r => r.Control == validationSet.Control).FirstOrDefault(); if (rule != null) { throw new InvalidOperationException(string.Format("Control {0} already have set of validations rule. You can create only one validation set for each control.", validationSet.Control)); } rules.Add(validationSet); }
internal ValidationBuilder(Control control) { var form = control.TopLevelControl; if (!(form is Form)) { throw new InvalidOperationException("Control must be on form"); } this.control = control; formValidator = FormValidator.GetValidator((Form)form); validationSet = formValidator.GetValidationSet(control); if (validationSet == null) { validationSet = new ValidationSet(formValidator, control); formValidator.AddValidationSet(validationSet); } }
/// <summary> /// Add new validation rule for control. /// </summary> internal void AddValidationSet(ValidationSet validationSet) { CheckThread(); // check if corresponding control already has validation rule var rule = rules.Where(r => r.Control == validationSet.Control).FirstOrDefault(); if (rule != null) throw new InvalidOperationException(string.Format("Control {0} already have set of validations rule. You can create only one validation set for each control.", validationSet.Control)); rules.Add(validationSet); }