/// <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.GetAssemplyQualifiedName(true)), _handler.Method.Name, _args.ToString()); }
/// <summary> /// Return a string representation of /// the object using the rule:// URI /// format. /// </summary> public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); if (_decorations.Count > 0) { sb.Append("?"); bool first = true; foreach (System.Collections.Generic.KeyValuePair <string, object> item in _decorations) { if (first) { first = false; } else { sb.Append("&"); } if (item.Key != null) { var itemString = Uri.EscapeDataString(item.Key); string valueString; if (item.Value == null) { valueString = string.Empty; } else { valueString = Uri.EscapeDataString(item.Value.ToString()); } sb.AppendFormat("{0}={1}", itemString, valueString); } } } return(sb.ToString()); }