private static SelectorMatch MatchUntilCombinator( IStyleable control, Selector start, bool subscribe, out Selector?combinator) { combinator = null; var activators = new AndActivatorBuilder(); var result = Match(control, start, subscribe, ref activators, ref combinator); return(result == SelectorMatchResult.Sometimes ? new SelectorMatch(activators.Get()) : new SelectorMatch(result)); }
private static SelectorMatchResult Match( IStyleable control, Selector selector, IStyle?parent, bool subscribe, ref AndActivatorBuilder activators, ref Selector?combinator) { var previous = selector.MovePrevious(); // Selectors are stored from right-to-left, so we recurse into the selector in order to // reverse this order, because the type selector will be on the left and is our best // opportunity to exit early. if (previous != null && !previous.IsCombinator) { var previousMatch = Match(control, previous, parent, subscribe, ref activators, ref combinator); if (previousMatch < SelectorMatchResult.Sometimes) { return(previousMatch); } } // Match this selector. var match = selector.Evaluate(control, parent, subscribe); if (!match.IsMatch) { combinator = null; return(match.Result); } else if (match.Activator is object) { activators.Add(match.Activator !); } if (previous?.IsCombinator == true) { combinator = previous; } return(match.Result); }