Esempio n. 1
0
        FilterResult Check(INode node)
        {
            if (!_settings.Accepts(node))
            {
                return(FilterResult.Skip);
            }

            return(_filter(node));
        }
Esempio n. 2
0
        public INode Next()
        {
            var node       = _reference;
            var beforeNode = _beforeNode;

            do
            {
                if (!beforeNode)
                {
                    node = _iterator.SkipWhile(m => !Object.ReferenceEquals(m, node)).Skip(1).FirstOrDefault();
                }

                if (node == null)
                {
                    return(null);
                }

                beforeNode = false;
            }while (!_settings.Accepts(node) || _filter.Invoke(node) != FilterResult.Accept);

            _beforeNode = false;
            _reference  = node;
            return(node);
        }
 /// <summary>
 /// Gets the elements that satisfy the provided filter settings.
 /// </summary>
 /// <typeparam name="T">The type of nodes to obtain.</typeparam>
 /// <param name="parent">The parent of the nodes to find.</param>
 /// <param name="filter">The filter settings to apply.</param>
 /// <returns>
 /// The filtered list of all descendents from the provided node.
 /// </returns>
 public static IEnumerable <T> GetElements <T>(this INode parent, FilterSettings filter)
     where T : class, INode
 {
     return(parent.GetElements <T>(predicate: (node => filter.Accepts(node))));
 }