/// <summary>
 /// Creates and initializes the rule.
 /// </summary>
 /// <param name="target">Object reference containing the data to validate.</param>
 /// <param name="handler">The address of the method implementing <see cref="ValidationRuleHandler"/>.</param>
 /// <param name="args">A <see cref="ValidationRuleArgs"/> object.</param>
 public ValidationRuleInfo(object target, ValidationRuleHandler handler, ValidationRuleArgs args)
 {
     _target = target;
      _handler = handler;
      _args = args;
      _ruleName = _handler.Method.Name + "!" + _args.ToString();
 }
Example #2
0
        /// <summary>
        /// Adds a rule to the list of validated rules.
        /// </summary>
        /// <remarks>
        /// <para>
        /// A rule is implemented by a method which conforms to the 
        /// method signature defined by the <see cref="ValidationRuleHandler" /> delegate.
        /// </para>
        /// </remarks>
        /// <param name="handler">The method that implements the rule.</param>
        /// <param name="args">
        /// A <see cref="ValidationRuleArgs"/> object specifying the property name and other arguments
        /// passed to the rule method
        /// </param>
        public void AddRule(ValidationRuleHandler handler, ValidationRuleArgs args)
        {
            // get the list of rules for the property
             List<ValidationRuleInfo> list = GetPropertyRules(args.PropertyName);

             // we have the list, add our new rule
             list.Add(new ValidationRuleInfo(_target, handler, args));
        }