public void AddRule(RuleHandler handler, RuleArgs args, int priority) { // get the list of rules for the property List <IRuleMethod> list = GetRulesForProperty(args.PropertyName, true).GetList(false); // we have the list, add our new rule list.Add(new RuleMethod(handler, args, priority)); }
/// <summary> /// Creates and initializes the rule. /// </summary> /// <param name="handler">The address of the method implementing the rule.</param> /// <param name="args">A RuleArgs object.</param> public RuleMethod(RuleHandler handler, RuleArgs args) { _handler = handler; _args = args; _ruleName = string.Format(@"rule://{0}/{1}/{2}", Uri.EscapeDataString(_handler.Method.DeclaringType.FullName), _handler.Method.Name, _args.ToString()); }
/// <summary> /// Gets the property name from the RuleArgs /// object, using the friendly name if one /// is defined. /// </summary> /// <param name="e">Object from which to /// extract the name.</param> /// <returns> /// The friendly property name if it exists, /// otherwise the property name itself. /// </returns> public static string GetPropertyName(RuleArgs e) { string propName = null; if (string.IsNullOrEmpty(e.PropertyFriendlyName)) { propName = e.PropertyName; } else { propName = e.PropertyFriendlyName; } return(propName); }
/// <summary> /// Creates and initializes the rule. /// </summary> /// <param name="handler">The address of the method implementing the rule.</param> /// <param name="args">A RuleArgs object.</param> /// <param name="priority"> /// Priority for processing the rule (smaller numbers have higher priority, default=0). /// </param> public RuleMethod(RuleHandler handler, RuleArgs args, int priority) : this(handler, args) { _priority = priority; }