Esempio n. 1
0
        private void Insert(StNode stNode, int level)
        {
            if (Level < 0)
            {
                throw new InvalidEnumArgumentException("level has to be greater than or equal to zero");
            }

            if (level < Level)
            {
                if (Parent != null)
                {
                    Parent.Insert(stNode, level);
                }
                else
                {
                    Parent = stNode;
                }
            }
            else if (level > Level)
            {
                var child = Children.FirstOrDefault();
                if (child != default(StNode))
                {
                    child.Insert(stNode, level);
                }
                else
                {
                    _children.Add(stNode);
                    stNode.Parent = this;
                }
            }
            else
            {
                if (IsRoot)
                {
                    throw new InvalidEnumArgumentException("could not insert at root level, root alreay present");
                }

                Parent.Children.Add(stNode);
                stNode.Parent = Parent;
            }
            stNode.ReArrange();
        }
Esempio n. 2
0
        private void Insert(StNode stNode, int level)
        {
            if (Level < 0) throw new InvalidEnumArgumentException("level has to be greater than or equal to zero");

            if (level < Level)
            {
                if (Parent != null)
                    Parent.Insert(stNode, level);
                else
                {
                    Parent = stNode;
                }
            }
            else if (level > Level)
            {
                var child = Children.FirstOrDefault();
                if (child != default(StNode))
                {
                    child.Insert(stNode, level);
                }
                else
                {
                    _children.Add(stNode);
                    stNode.Parent = this;
                }
            }
            else
            {
                if (IsRoot)
                    throw new InvalidEnumArgumentException("could not insert at root level, root alreay present");

                Parent.Children.Add(stNode);
                stNode.Parent = Parent;
            }
            stNode.ReArrange();
        }
Esempio n. 3
0
 private void Add(StNode stNode)
 {
     Children.Add(stNode);
     stNode.Parent = this;
     stNode.ReArrange();
 }
Esempio n. 4
0
 private void Add(StNode stNode)
 {
     Children.Add(stNode);
     stNode.Parent = this;
     stNode.ReArrange();
 }