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); } } }
protected override bool Match(Control control, SelectorPathNode path) { if (control.Classes.Count == 0) { return(false); } return(_classes.Any(clazz => control.Classes.Contains(clazz))); }
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)); }
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.") });
protected override bool Match(Control control, SelectorPathNode path) { return(_parentSelector.MatchControl(control, path) && _condition(control, path)); }
protected abstract bool Match(Control control, SelectorPathNode path);
internal bool MatchControl(Control control, SelectorPathNode path) => Match(control, path);
protected override bool Match(Control control, SelectorPathNode path) { return(control.Id == null ? false : _ids.Contains(control.Id)); }
protected override bool Match(Control control, SelectorPathNode path) { return(!_selector.MatchControl(control, path)); }
protected override bool Match(Control control, SelectorPathNode path) { return(_types.Contains(control.GetType())); }