Esempio n. 1
0
        public virtual void AddChild(TreeItem <T> child)
        {
            child.ThrowArgumentExceptionIfNull(nameof(child));

            child.parent = this;
            this.children.Add(child);
        }
Esempio n. 2
0
        public static void CreateTree <T>(this TreeItem <T> parent, Func <T, IEnumerable <T> > getChildren)
        {
            parent.ThrowArgumentExceptionIfNull(nameof(parent));
            getChildren.ThrowArgumentExceptionIfNull(nameof(getChildren));

            var children = getChildren(parent.Item).Select(c => new TreeItem <T>(c)).ToList();

            parent.AddChildren(children);
            foreach (var child in children)
            {
                child.CreateTree(getChildren);
            }
        }