protected override bool MatchMethod(Control element, SimpleCssSelectorElement selectorElement) { if (!selectorElement.Id.IsEmpty() && !selectorElement.Id.EqualsIgnoreCase(element.ClientID)) { return(false); } var osControl = element as IOSControl; if (osControl != null) { return(MatchControl(selectorElement, osControl.TagName, osControl.CssClass)); } var htmlControl = element as HtmlControl; if (htmlControl != null) { string[] cssClass = (htmlControl.Attributes["class"] ?? string.Empty).Split(' '); return(MatchControl(selectorElement, htmlControl.TagName, cssClass)); } // these fallbacks are only for hierarchy search ..if its not a IOSControl we may will be able to set the style later var wc = element as WebControl; if (wc != null) { return(MatchControl(selectorElement, null, wc.CssClass.Split(' '))); } return(false); }
private bool MatchControl(SimpleCssSelectorElement selectorElement, string tag, string[] cssClass) { if (!selectorElement.Tag.IsEmpty() && selectorElement.Tag != "*" && (tag == null || !selectorElement.Tag.EqualsIgnoreCase(tag))) { return(false); } if (!selectorElement.Classes.All(@class => cssClass.Any(elementClass => elementClass.EqualsIgnoreCase(@class)))) { return(false); } return(true); }
protected abstract bool MatchMethod(Type element, SimpleCssSelectorElement selectorElement);