Пример #1
0
        public override MatchResult Match <TDependencyObject, TDependencyProperty>(StyleSheet styleSheet, ref IDomElement <TDependencyObject, TDependencyProperty> domElement, SelectorMatcher[] fragments, ref int currentIndex)
        {
            if (!domElement.HasAttribute(PropertyName))
            {
                return(MatchResult.ItemFailed);
            }

            var dependencyProperty = domElement.Attributes[PropertyName];

            domElement.EnsureAttributeWatcher(dependencyProperty);

            // just check if it exists - here: is not null
            if (Value == null)
            {
                return(domElement.GetAttributeValue(dependencyProperty) != null ? MatchResult.Success : MatchResult.ItemFailed);
            }

            if (Operator == "=")
            {
                return(domElement.GetAttributeValue(dependencyProperty)?.ToString() == Value ? MatchResult.Success : MatchResult.ItemFailed);
            }

            //else if (Operator == "~=")
            //{
            //    var v = domElement.GetAttributeValue(dependencyProperty);
            //    if (v is IEnumerable e)
            //    {
            //        foreach (var item in e)
            //        {
            //            if (item?.ToString() == Value)
            //            {
            //                return MatchResult.Success;
            //            }
            //        }
            //    }

            //    return MatchResult.ItemFailed;
            //}
            //else if (Operator == "|=")
            //{
            //    var v = domElement.GetAttributeValue(dependencyProperty);
            //    if (v is IEnumerable e)
            //    {
            //        foreach (var item in e)
            //        {
            //            if (item?.ToString() == Value)
            //            {
            //                return MatchResult.Success;
            //            }
            //        }
            //    }

            //    return MatchResult.ItemFailed;
            //}

            return(MatchResult.ItemFailed);
        }