示例#1
0
        private IEnumerable <Control> FindMatchingControls(Component searchRoot, SelectorPathNode path, Selector selector)
        {
            path = new SelectorPathNode()
            {
                Prev = path, Control = searchRoot
            };

            if (selector.MatchControl(searchRoot, path))
            {
                yield return(searchRoot);
            }

            foreach (var control in Children)
            {
                if (control is Component component)
                {
                    foreach (var subControl in component.FindMatchingControls(component, path, selector))
                    {
                        yield return(subControl);
                    }
                }

                if (selector.MatchControl(control, path))
                {
                    yield return(control);
                }
            }
        }
示例#2
0
        protected override bool Match(Control control, SelectorPathNode path)
        {
            if (control.Classes.Count == 0)
            {
                return(false);
            }

            return(_classes.Any(clazz => control.Classes.Contains(clazz)));
        }
示例#3
0
        protected override bool Match(Control control, SelectorPathNode path)
        {
            if (control.Parent == null)
            {
                return(false);
            }

            return(_parentSelector.MatchControl(control.Parent, path.Prev) &&
                   _selector.MatchControl(control, path));
        }
示例#4
0
 protected override bool Match(Control control, SelectorPathNode path)
 {
     return(_chainOperator switch
     {
         ChainOperator.And => _prevSelector.MatchControl(control, path) &&
         _nextSelector.MatchControl(control, path),
         ChainOperator.Or => _prevSelector.MatchControl(control, path) ||
         _nextSelector.MatchControl(control, path),
         ChainOperator.Xor => _prevSelector.MatchControl(control, path) !=
         _nextSelector.MatchControl(control, path),
         _ => throw new ArgumentException("Invalid chain operator.")
     });
示例#5
0
 protected override bool Match(Control control, SelectorPathNode path)
 {
     return(_parentSelector.MatchControl(control, path) && _condition(control, path));
 }
示例#6
0
 protected abstract bool Match(Control control, SelectorPathNode path);
示例#7
0
 internal bool MatchControl(Control control, SelectorPathNode path) => Match(control, path);
示例#8
0
 protected override bool Match(Control control, SelectorPathNode path)
 {
     return(control.Id == null ? false : _ids.Contains(control.Id));
 }
示例#9
0
 protected override bool Match(Control control, SelectorPathNode path)
 {
     return(!_selector.MatchControl(control, path));
 }
示例#10
0
 protected override bool Match(Control control, SelectorPathNode path)
 {
     return(_types.Contains(control.GetType()));
 }