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()); }
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()); }