Exemplo n.º 1
0
        private static void TestNestedObjects()
        {
            var nodelist = new List<StNode>
                           {
                               new StNode("Karnataka"),
                               new StNode("TamilNadu"),
                               new StNode("AndhraPradesh"),
                               new StNode("Orissa"),
                               new StNode("Delhi"),

                           };

            var nodelist2 =
                new List<StNode>
                           {

                               new StNode("District1"),
                               new StNode("District2"),
                               new StNode("District3"),
                               new StNode("District4"),
                               new StNode("District6"),
                               new StNode("District5")
                           };

            nodelist[4].Add(nodelist2);

            StNode District5 = nodelist2[5];
            StNode stNode = new StNode("India");

            stNode.Insert(nodelist, 2);

            Console.WriteLine(District5.Nodeid == 21 ? "success TestNestedObjects" : "fail TestNestedObjects");
        }
Exemplo n.º 2
0
        private static void TestBulkInsert()
        {
            var nodelist = new List<StNode>
                           {
                               new StNode("Karnataka"),
                               new StNode("TamilNadu"),
                               new StNode("AndhraPradesh"),
                               new StNode("Orissa"),
                               new StNode("Delhi"),

                           };

            var nodelist2 =
                new List<StNode>
                           {

                               new StNode("District1"),
                               new StNode("District2"),
                               new StNode("District3"),
                               new StNode("District4"),
                               new StNode("District6"),
                               new StNode("District5")
                           };

            StNode stNode = new StNode("India");
            stNode.Insert(nodelist, 1);
            nodelist[1].Add(nodelist2);

            Console.WriteLine(nodelist[1].Children[1].Nodeid == 21? "success TestBulkInsert" : "fail TestBulkInsert") ;
        }
Exemplo n.º 3
0
        private static void TestNestedObjects()
        {
            var nodelist = new List <StNode>
            {
                new StNode("Karnataka"),
                new StNode("TamilNadu"),
                new StNode("AndhraPradesh"),
                new StNode("Orissa"),
                new StNode("Delhi"),
            };

            var nodelist2 =
                new List <StNode>
            {
                new StNode("District1"),
                new StNode("District2"),
                new StNode("District3"),
                new StNode("District4"),
                new StNode("District6"),
                new StNode("District5")
            };

            nodelist[4].Add(nodelist2);

            StNode District5 = nodelist2[5];
            StNode stNode    = new StNode("India");

            stNode.Insert(nodelist, 2);

            Console.WriteLine(District5.Nodeid == 21 ? "success TestNestedObjects" : "fail TestNestedObjects");
        }
Exemplo n.º 4
0
        private static void TestBulkInsert()
        {
            var nodelist = new List <StNode>
            {
                new StNode("Karnataka"),
                new StNode("TamilNadu"),
                new StNode("AndhraPradesh"),
                new StNode("Orissa"),
                new StNode("Delhi"),
            };

            var nodelist2 =
                new List <StNode>
            {
                new StNode("District1"),
                new StNode("District2"),
                new StNode("District3"),
                new StNode("District4"),
                new StNode("District6"),
                new StNode("District5")
            };



            StNode stNode = new StNode("India");

            stNode.Insert(nodelist, 1);
            nodelist[1].Add(nodelist2);

            Console.WriteLine(nodelist[1].Children[1].Nodeid == 21? "success TestBulkInsert" : "fail TestBulkInsert");
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 private void Add(StNode stNode)
 {
     Children.Add(stNode);
     stNode.Parent = this;
     stNode.ReArrange();
 }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
 private void Add(StNode stNode)
 {
     Children.Add(stNode);
     stNode.Parent = this;
     stNode.ReArrange();
 }