Пример #1
0
        /// <summary>
        /// Remove descendant nodes from a parent <see cref="PrtgNode"/>.
        /// </summary>
        /// <typeparam name="TRoot">The type of the root node.</typeparam>

        /// <param name="root">The node to remove child nodes from.</param>
        /// <param name="nodes">The nodes to remove. If this value is null or empty, no nodes will be removed.</param>
        /// <returns></returns>
        internal static TRoot RemoveNodes <TRoot>(TRoot root, IEnumerable <PrtgNode> nodes) where TRoot : PrtgNode
        {
            if (nodes == null)
            {
                return(root);
            }

            var list = nodes.ToArray();

            if (list.Length == 0)
            {
                return(root);
            }

            var remover = new PrtgNodeRemover(list);

            return((TRoot)remover.Visit(root));
        }
Пример #2
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with specified descendant nodes removed.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The node to remove descendant nodes from.</param>
 /// <param name="nodes">The nodes to remove. If this value is empty or null, no nodes will be removed.</param>
 /// <returns>If any nodes were specified, a new node with those descendants removed. Otherwise, the original node.</returns>
 public static TRoot RemoveNodes <TRoot>(this TRoot root, IEnumerable <PrtgNode> nodes) where TRoot : PrtgNode =>
 PrtgNodeRemover.RemoveNodes(root, nodes);