Esempio n. 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();
        }
Esempio n. 2
0
        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());
            manager.Strategies.Add( new RecordModelInventorization());
              }

               // if (config.Root["any"].Exists)
               //  manager.OnlyAttributed = false;

            var result = new XMLConfiguration();
            result.Create("inventory");
            manager.Run(result.Root);
            Console.WriteLine(result.SaveToString());
        }