protected override SelectorMatch Evaluate(IStyleable control, bool subscribe) { ILogical c = (ILogical)control; List <IObservable <bool> > descendantMatches = new List <IObservable <bool> >(); while (c != null) { c = c.LogicalParent; if (c is IStyleable) { var match = _parent.Match((IStyleable)c, subscribe); if (match.Result == SelectorMatchResult.Sometimes) { descendantMatches.Add(match.Activator); } else if (match.IsMatch) { return(SelectorMatch.AlwaysThisInstance); } } } if (descendantMatches.Count > 0) { return(new SelectorMatch(StyleActivator.Or(descendantMatches))); } else { return(SelectorMatch.NeverThisInstance); } }
protected override SelectorMatch Evaluate(IStyleable control, bool subscribe) { var activators = new List <IObservable <bool> >(); var neverThisInstance = false; foreach (var selector in _selectors) { var match = selector.Match(control, subscribe); switch (match.Result) { case SelectorMatchResult.AlwaysThisType: case SelectorMatchResult.AlwaysThisInstance: return(match); case SelectorMatchResult.NeverThisInstance: neverThisInstance = true; break; case SelectorMatchResult.Sometimes: activators.Add(match.Activator); break; } } if (activators.Count > 1) { return(new SelectorMatch(StyleActivator.Or(activators))); } else if (activators.Count == 1) { return(new SelectorMatch(activators[0])); } else if (neverThisInstance) { return(SelectorMatch.NeverThisInstance); } else { return(SelectorMatch.NeverThisType); } }
protected override SelectorMatch Evaluate(IStyleable control, bool subscribe) { ILogical c = (ILogical)control; List <IObservable <bool> > descendantMatches = new List <IObservable <bool> >(); while (c != null) { c = c.LogicalParent; if (c is IStyleable) { var match = _parent.Match((IStyleable)c, subscribe); if (match.ImmediateResult != null) { if (match.ImmediateResult == true) { return(SelectorMatch.True); } } else { descendantMatches.Add(match.ObservableResult); } } } if (descendantMatches.Count > 0) { return(new SelectorMatch(StyleActivator.Or(descendantMatches))); } else { return(SelectorMatch.False); } }