Пример #1
0
        /// <inheritdoc />
        public override int CountAt(IXmlPathLoose searchedPath, string expectedValue, Options options)
        {
            if (searchedPath == null)
            {
                throw new ArgumentNullException("searchedPath");
            }

            if (searchedPath.IsEmpty)
            {
                return(0);
            }

            IXmlPathLoose[] array = searchedPath.AsArray();
            var             head  = array[0] as XmlPathLooseOpenElement;

            if (head == null || !AreNamesEqual(head.Name, options))
            {
                return(0);
            }

            IXmlPathLoose trail = searchedPath.Trail();

            if (!trail.IsEmpty)
            {
                return(Attributes.CountAt(trail, expectedValue, options) + Children.CountAt(trail, expectedValue, options));
            }

            if (expectedValue == null)
            {
                return(1);
            }

            if (Children.Count != 1)
            {
                return(0);
            }

            var content = Children[0] as NodeContent;

            return(((content != null) && content.AreValuesEqual(expectedValue, options)) ? 1 : 0);
        }