Beispiel #1
0
        public static void Run()
        {
            var conf = new XMLConfiguration();

            conf.Create();

            conf.Root.Name = "This-is-Root";
            var child1 = conf.Root.AddChildNode("Child_Node_1");
            child1.AddChildNode("Grand-Child-1", "this is my value");

            child1.AddAttributeNode("AttrWithoutValue");
            child1.AddAttributeNode("Important", true);
            child1.AddAttributeNode("Age", 88);
            child1.AddAttributeNode("DateOf-Enlightement", App.LocalizedTime);
            child1.AddAttributeNode("HowFakeFakeAreYou", FakeType.TotalFraud);

            conf.Root.AddChildNode("Child2").AddChildNode("A").AddChildNode("B").AddChildNode("C");

            conf.Root["Child2"]["A"]["B"]["C"].Value = "175";
            Console.WriteLine(conf.Root["Child2"]["A"]["B"]["C"].ValueAsInt());

            Console.WriteLine(conf.SaveToString(null));

            conf.SaveAs("c:\\TEST.xml");

            conf = new XMLConfiguration("c:\\TEST.xml");
            Console.WriteLine(conf.Root["Child2"]["A"]["B"]["C"].ValueAsInt());
            Console.WriteLine(conf.Root["Child_Node_1"].AttrByName("HowFakeFakeAreYou").ValueAsEnum<FakeType>(FakeType.RealStuff));

            Console.ReadLine();
        }