コード例 #1
0
        public void TestConfNodeEditor_AddNode_ToTagParent()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/DefaultSpec.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");
            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");

            var node = conf.Find(@"Specs/BR", new List <string>()
            {
                "HighTemp"
            });

            Assert.IsTrue(node == null);

            ConfTree newnode = new ConfTree("BR");

            newnode.Add(new ConfItem("Max", "10"));
            newnode.Add(new ConfItem("Min", "0"));
            var tree = conf.GetItem(@"HighTemp:Specs") as ConfTree;

            tree.AddNode(newnode);
            conf.Save();

            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");
            node = conf.Find(@"Specs/BR", new List <string>()
            {
                "HighTemp"
            });
            Assert.IsTrue(node != null);
        }
コード例 #2
0
        private void BTN_Add_Click(object sender, EventArgs e)
        {
            var data = DGV_NewNodeInfo.DataSource as DataTable;

            ConfItem newnode;

            if (data.Columns.Count > 2)//ConfTree
            {
                newnode = _tree.Sons[0].Clone();

                var newtree = newnode as ConfTree;
                newtree.Clear();
                newtree.Name = data.Rows[0][0] as string;

                for (int i = 1; i < data.Rows.Count; i++)
                {
                    if (!string.IsNullOrEmpty(data.Rows[i][1] as string))
                    {
                        newtree[data.Rows[i][1] as string] = data.Rows[i][2] as string;
                    }
                }
            }
            else
            {
                return;
            }

            _tree.AddNode(newnode);
            _root.Save();

            _onChange.Invoke();
        }
コード例 #3
0
        public void TestConfNodeEditor_GetSonStructure()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/DefaultSpec.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");
            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");

            var item = (conf.GetItem(@"Specs") as ConfTree).Sons[0].Clone();

            Assert.IsTrue(item != null);
        }
コード例 #4
0
ファイル: TestXmlBuild.cs プロジェクト: shiningstone/ConfMgmt
        public void TestBuild_Xml_MultiLevel()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/MultiLevel.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");

            JbAssert.Equal(conf["Item1"], "1.1");
            JbAssert.Equal(conf[@"Level1/Item1"], "1.1");
            JbAssert.Equal(conf[@"MultiLevel/Level1/Item1"], "1.1");

            JbAssert.Equal(conf["Item2"], "2.1");
            JbAssert.Equal(conf[@"Level2/Item2"], "2.1");
            JbAssert.Equal(conf[@"MultiLevel/Level1/Level2/Item2"], "2.1");
            JbAssert.Equal(conf["Item22"], "2.2");

            JbAssert.Equal(conf["Item3"], "3.1");
            JbAssert.Equal(conf[@"Level3/Item3"], "3.1");
            JbAssert.Equal(conf[@"MultiLevel/Level1/Level2/Level3/Item3"], "3.1");
        }
コード例 #5
0
        public void TestConfNodeEditor_RemoveNode()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/DefaultSpec.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");
            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");

            var node = conf.Find(@"Specs/Ith", new List <string>()
            {
                "HighTemp"
            });

            Assert.IsTrue(node != null);

            conf.RemoveNode(node);

            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");
            node = conf.Find(@"Specs/Ith", new List <string>()
            {
                "HighTemp"
            });
            Assert.IsTrue(node == null);
        }
コード例 #6
0
 private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
 {
     _conf[e.ChangedItem.Label] = e.ChangedItem.Value as string;
     _conf.Save();
 }