Пример #1
0
        private bool IsUnder(NodeQueryMarcher matcher, SearchResult result)
        {
            if (!(result.Node is ParentedNode parented))
            {
                return(true);
            }

            foreach (var parent in parented.GetParentChain())
            {
                if (matcher.IsMatch(parent) != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        private void Visit(object node, NodeQueryMarcher matcher, CancellationTokenSource cancellationTokenSource)
        {
            if (cancellationTokenSource.IsCancellationRequested)
            {
                return;
            }

            if (resultSet.Count > MaxResults)
            {
                cancellationTokenSource.Cancel();
                return;
            }

            var result = matcher.IsMatch(node);

            if (result != null)
            {
                result.Node = node;
                resultSet.Add(result);
            }
        }