/// <summary> /// Adds a top-level rule for the element. /// </summary> /// <param name="builder">The selector function.</param> public IRuleAppender Treat(Func <IRuleSelector, IRuleBuilder> builder) { Precondition.Require(builder, () => Error.ArgumentNull("inner")); IRuleBuilder rule = builder(this); HtmlElementRule elem = (rule as HtmlElementRule); HtmlAttributeRule attr = (rule as HtmlAttributeRule); HtmlElementRuleCollection ec = (rule as HtmlElementRuleCollection); HtmlAttributeRuleCollection ac = (rule as HtmlAttributeRuleCollection); if (elem != null) { AddElementRule(elem); } else if (ec != null) { AddElementRules(ec); } else if (attr != null) { AddAttributeRule(attr); } else if (ac != null) { AddAttributeRules(ac); } else { throw Error.UnsupportedElementRule("builder"); } return(this); }
public HtmlAttributeContext(HtmlAttributeRule rule, IValueSet parameters) : base(parameters) { Precondition.Require(rule, () => Error.ArgumentNull("rule")); _rule = rule; }
protected HtmlAttributeResult ConvertAttribute(HtmlElementRule element, XmlAttribute attribute) { HtmlAttributeRule attrRule = GetAttributeRule(element, attribute.LocalName); HtmlAttributeContext context = new HtmlAttributeContext(attrRule.Clone(), Parameters); if (attrRule.HasConverter) { attribute = attrRule.Converter(context, attribute); if (attribute == null) { return(null); } if (!MatchName(attribute, attrRule)) { attrRule = GetAttributeRule(element, attribute.LocalName); } if ((attrRule.Options & HtmlAttributeOptions.Generated) == HtmlAttributeOptions.Generated) { attrRule = attrRule.Clone(); attrRule.Options |= HtmlAttributeOptions.Allowed; } } return(new HtmlAttributeResult(attribute, attrRule)); }
internal HtmlAttributeRule Clone(HtmlElementRule parent) { HtmlAttributeRule current = Clone(); current._element = parent; return(current); }
public virtual HtmlAttributeRule AddAttributeRule(HtmlAttributeRule rule) { Precondition.Require(rule, () => Error.ArgumentNull("rule")); HtmlAttributeRule current = (rule.Element == this) ? rule : rule.Clone(this); _attributes[current.Name] = current; return(current); }
public HtmlAttributeRule Clone() { HtmlAttributeRule current = new HtmlAttributeRule(_element, _name, _options); current._converter = _converter; current._defaultValue = _defaultValue; current._pattern = _pattern; return(current); }
public HtmlAttributeResult(XmlAttribute attribute, HtmlAttributeRule rule) { Precondition.Require(attribute, () => Error.ArgumentNull("attribute")); Precondition.Require(rule, () => Error.ArgumentNull("rule")); _attribute = attribute; _rule = rule; }
public override bool Equals(object obj) { if (Object.ReferenceEquals(this, obj)) { return(true); } HtmlAttributeRule rule = (obj as HtmlAttributeRule); if (Object.ReferenceEquals(rule, null)) { return(false); } if (rule.Name.Equals(_name, StringComparison.OrdinalIgnoreCase)) { return(_element.Equals(rule._element)); } return(false); }
/// <summary> /// Adds a top-level rule for the attribute. In most cases, the rule is ignored. /// </summary> /// <param name="rule">A new sub-rule to add.</param> protected virtual HtmlAttributeRule AddAttributeRule(HtmlAttributeRule rule) { Precondition.Require(rule, () => Error.ArgumentNull("rule")); return Document.AddAttributeRule(rule); }
public HtmlAttributeContext(HtmlAttributeRule rule) : this(rule, null) { }
protected bool MatchName(XmlAttribute attribute, HtmlAttributeRule rule) { return(String.Equals(attribute.LocalName, rule.Name, StringComparison.OrdinalIgnoreCase)); }
public HtmlAttributeRule Clone() { HtmlAttributeRule current = new HtmlAttributeRule(_element, _name, _options); current._converter = _converter; current._defaultValue = _defaultValue; current._pattern = _pattern; return current; }
protected bool MatchName(XmlAttribute attribute, HtmlAttributeRule rule) { return String.Equals(attribute.LocalName, rule.Name, StringComparison.OrdinalIgnoreCase); }
/// <summary> /// Adds a top-level rule for the attribute. In most cases, the rule is ignored. /// </summary> /// <param name="rule">A new sub-rule to add.</param> protected virtual HtmlAttributeRule AddAttributeRule(HtmlAttributeRule rule) { Precondition.Require(rule, () => Error.ArgumentNull("rule")); return(Document.AddAttributeRule(rule)); }
public virtual HtmlAttributeRule AddAttributeRule(HtmlAttributeRule rule) { Precondition.Require(rule, () => Error.ArgumentNull("rule")); HtmlAttributeRule current = (rule.Element == this) ? rule : rule.Clone(this); _attributes[current.Name] = current; return current; }