Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 protected abstract bool MatchMethod(Type element, SimpleCssSelectorElement selectorElement);