public override void Report(System.IO.TextWriter writer) { var conf = new XMLConfiguration(); conf.StrictNames = false; conf.Create(); conf.Root.Name = "health-check-list"; conf.Root.AddAttributeNode("successful", CheckList.Successful); var runNode = conf.Root.AddChildNode("run", null); if (CheckList.Status == CheckListStatus.Run) { runNode.AddAttributeNode("started", CheckList.RunStart); runNode.AddAttributeNode("finished", CheckList.RunFinish); runNode.AddAttributeNode("duration", CheckList.RunFinish - CheckList.RunStart); } else { runNode.AddAttributeNode("started", "never ran"); } var checksNode = conf.Root.AddChildNode("checks", null); foreach (var check in CheckList.Checks) { reportCheck(checksNode, check); } writer.Write(conf.ToString()); }
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(); }
private static void run(string[] args) { var config = new CommandArgsConfiguration(args); if (config.Root["?"].Exists || config.Root["h"].Exists || config.Root["help"].Exists) { ConsoleUtils.WriteMarkupContent(typeof(Program).GetText("Help.txt")); return; } if (!config.Root.AttrByIndex(0).Exists) { Console.WriteLine("Specify ';'-delimited assembly list"); return; } var manager = new InventorizationManager(config.Root.AttrByIndex(0).Value); var fnode = config.Root["f"]; if (!fnode.Exists) { fnode = config.Root["filter"]; } if (fnode.Exists) { ConfigAttribute.Apply(manager, fnode); } foreach (var n in config.Root.Children.Where(chi => chi.IsSameName("s") || chi.IsSameName("strat") || chi.IsSameName("strategy"))) { var tname = n.AttrByIndex(0).Value ?? "<unspecified>"; Type t = Type.GetType(tname); if (t == null) { throw new NFXException("Can not create strategy type: " + tname); } var strategy = Activator.CreateInstance(t) as IInventorization; if (strategy == null) { throw new NFXException("The supplied type is not strategy: " + tname); } manager.Strategies.Add(strategy); } if (manager.Strategies.Count == 0) { manager.Strategies.Add(new BasicInventorization()); } // if (config.Root["any"].Exists) // manager.OnlyAttributed = false; var result = new XMLConfiguration(); result.Create("inventory"); manager.Run(result.Root); Console.WriteLine(result.SaveToString()); }