示例#1
0
        protected override SelectorMatch Evaluate(IStyleable control, bool subscribe)
        {
            var c = (ILogical)control;
            var descendantMatches = new OrActivatorBuilder();

            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(descendantMatches.Get()));
            }
            else
            {
                return(SelectorMatch.NeverThisInstance);
            }
        }
示例#2
0
        protected override SelectorMatch Evaluate(IStyleable control, bool subscribe)
        {
            var activators        = new OrActivatorBuilder();
            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 > 0)
            {
                return(new SelectorMatch(activators.Get()));
            }
            else if (neverThisInstance)
            {
                return(SelectorMatch.NeverThisInstance);
            }
            else
            {
                return(SelectorMatch.NeverThisType);
            }
        }