Exemple #1
0
        private static void SampleTwo(string[] args)
        {
            var argThings = new ArgsActions();

            argThings.SetOption("-a", () => Console.WriteLine("-a option selected"));
            argThings.SetOption("-e", () => Console.WriteLine("-e option selected"));

            var processor = new ArgsProcessor(argThings);

            processor.Process(args);
        }
Exemple #2
0
        public static void  Test()
        {
            //实际上就是一种表驱动编程方法的实践
            Console.WriteLine("【委托的使用,字典的使用,以及[,]多维操作符的自定义】");
            ArgsActions aas = new ArgsActions();
            DoAction    da  = new DoAction();
            Action      a1  = da.PrintAdd;
            Action      a2  = da.PrintMod;

            aas.SetOption("add", a1);
            aas.SetOption("mod", a2);
            ArgsProcessor ap = new ArgsProcessor(aas);

            ap.Process(new string[] { "add", "mod" });
        }
Exemple #3
0
 public ArgsProcessor(ArgsActions actions)
 {
     this.actions = actions;
 }