Ejemplo n.º 1
0
        private static SelectorMatch MatchDescendent(IStyleable control, Selector previous)
        {
            ILogical c = (ILogical)control;
            List <IObservable <bool> > descendentMatches = new List <IObservable <bool> >();

            while (c != null)
            {
                c = c.LogicalParent;

                if (c is IStyleable)
                {
                    var match = previous.Match((IStyleable)c);

                    if (match.ImmediateResult != null)
                    {
                        if (match.ImmediateResult == true)
                        {
                            return(SelectorMatch.True);
                        }
                    }
                    else
                    {
                        descendentMatches.Add(match.ObservableResult);
                    }
                }
            }

            return(new SelectorMatch(StyleActivator.Or(descendentMatches)));
        }
Ejemplo n.º 2
0
        protected override SelectorMatch Evaluate(IStyleable control, bool subscribe)
        {
            ILogical c = (ILogical)control;
            List <IObservable <bool> > descendentMatches = 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
                    {
                        descendentMatches.Add(match.ObservableResult);
                    }
                }
            }

            if (descendentMatches.Count > 0)
            {
                return(new SelectorMatch(StyleActivator.Or(descendentMatches)));
            }
            else
            {
                return(SelectorMatch.False);
            }
        }