コード例 #1
0
        static void Main(string[] args)
        {
            CLIBase cli = new CLIBase();

            cli.Plugins.AddRange(typeof(Program).FindPlugins());
            cli.Run();
        }
コード例 #2
0
        public bool Execute(CLIBase parent, CliCommand Input)
        {
            switch (Input.Command)
            {
            case "t1":
                Example1();
                break;

            case "t2":
                Example2();
                break;

            case "t3":
                Example3();
                break;

            case "t4":
                Example4();
                break;

            case "t5":
                Example5();
                break;

            case "t6":
                Example6();
                break;

            case "pool":
                ExamplePool();
                break;
            }
            return(true);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ladybel/BudgetBeheer
        static void Main(string[] args)
        {
            CLIBase cli = new CLIBase();

            cli.Plugins.Add(new LinqDemoPlugin());
            cli.Run(args);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: filipgeens/Syntra2021
        static void Main(string[] args)
        {
            CLIBase cli = new CLIBase();

            cli.Plugins.AddRange(DynamicPlugis.FindAll(@"CliDemo\Plugins"));
            cli.Run(args);
        }
コード例 #5
0
ファイル: ScheldUit.cs プロジェクト: filipgeens/Syntra2021
        public bool Execute(CLIBase parent, CliCommand Input)
        {
            string res = null;

            switch (Input.Command)
            {
            case "scheld":
                if (Input.Count > 0)
                {
                    res = $"{Input[0]} is een dik varken, een onozelaar en een lapzwans!";
                }
                else
                {
                    res = "Pipo, kieken, varken en alles wat lelijk is";
                }
                break;

            default:
                return(false);
            }
            if (res?.Length > 0)
            {
                parent.ShowInColor(res, ConsoleColor.DarkRed, ConsoleColor.Green);
                return(true);
            }
            return(false);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: filipgeens/Syntra2021
        static void Main(string[] args)
        {
            CLIBase cli = new CLIBase();

            //   cli.Plugins.Add(new ThreadExamples());
            cli.Plugins.Add(new TaskExamples());
            cli.Run();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: ladybel/BudgetBeheer
        static void Main(string[] args)
        {
            CLIBase cli = new CLIBase();

            cli.Plugins.Add(new HalloCliPlugin());
            cli.Plugins.Add(new OlaPlugin());
            cli.Run(args);
        }
コード例 #8
0
 public bool Execute(CLIBase parent, CliCommand Input)
 {
     if (Input.Command == "ola")
     {
         Console.WriteLine("Ola Pola");
         return(true);
     }
     return(false);
 }
コード例 #9
0
 public bool Execute(CLIBase parent, CliCommand Input)
 {
     if (Input.Command == "hallo")
     {
         Console.WriteLine("Hallo iedereen !!");
         return(true);
     }
     return(false);
 }
コード例 #10
0
 public bool Execute(CLIBase parent, CliCommand Input)
 {
     switch (Input.Command)
     {
     case "singleton":
         Console.WriteLine(SingletonDemo.Instance.Talk());
         return(true);
     }
     return(false);
 }
コード例 #11
0
 public bool Execute(CLIBase parent, CliCommand Input)
 {
     switch (Input.Command)
     {
     case "transport":
         if (Input.Count > 1)
         {
             if (int.TryParse(Input[0], out int nPassengers) && int.TryParse(Input[1], out int distance))
             {
                 ITransportFactory f = new ComplexFactory();
                 Console.WriteLine(f.SelectBest(nPassengers, distance)?.Name ?? "No transport");
                 return(true);
             }
         }
         break;
     }
     return(false);
 }
コード例 #12
0
        public bool Execute(CLIBase parent, CliCommand Input)
        {
            switch (Input.Command)
            {
            case "t1":
                Console.WriteLine();
                Example1();
                break;

            case "t2":
                Example2();
                break;

            case "t3":
                Example3();
                break;

            default:
                return(false);
            }
            return(true);
        }
コード例 #13
0
        public bool Execute(CLIBase parent, CliCommand input)
        {
            switch (input.Command)
            {
            case "json.add":
                if (input.Parameters?.Count >= 2)
                {
                    _data = new PrivateData()
                    {
                        VoorNaam            = input.Parameters[0],
                        AchterNaam          = input.Parameters[1],
                        RijksregisterNummer = input.GetParameter(2, "---------"),
                        BankRekeningNummer  = input.GetParameter(3, "----------"),
                    };
                    if (DateTime.TryParse(input.GetParameter(4, DateTime.MinValue.ToString()), out DateTime bd))
                    {
                        _data.GeboorteDatum = bd;
                    }
                    if (int.TryParse(input.GetParameter(5, "0000"), out int p))
                    {
                        _data.Pincode = p;
                    }
                    for (int i = 6; i < input.Parameters.Count; i++)
                    {
                        _data.PrivateRelaties.Add(input.Parameters[i]);
                    }
                    _json = JsonSerializer.Serialize(_data, new JsonSerializerOptions()
                    {
                        WriteIndented = true, IgnoreNullValues = true
                    });
                    goto case "json.print";
                }
                break;

            case "json.print":
                if (_data != null)
                {
                    Console.WriteLine("Data object content:");
                    Console.WriteLine(_data);
                    Console.WriteLine();
                }
                if (_json?.Length > 0)
                {
                    Console.WriteLine("Json serialized data:");
                    Console.WriteLine(_json);
                    Console.WriteLine();
                }
                break;

            case "json.save":
                if (Directory.Exists(Path.GetDirectoryName(BestandsNaam(input))))
                {
                    File.WriteAllText(BestandsNaam(input), _json);
                    Console.WriteLine($"Uw data is opgeslagen in de file '{_bestand}'");
                }
                else
                {
                    Console.WriteLine($"{Path.GetDirectoryName(_bestand)} is niet gekend");
                }
                break;

            case "json.load":
                if (File.Exists(BestandsNaam(input)))
                {
                    _data = null;
                    _json = File.ReadAllText(BestandsNaam(input));
                    if (_json.NotEmpty())
                    {
                        _data = JsonSerializer.Deserialize <PrivateData>(_json);
                        goto case "json.print";
                    }
                }
                break;

            case "json.list":
                string dir = input.GetParameter(0, Directory.GetCurrentDirectory());
                if (Directory.Exists(dir))
                {
                    Console.WriteLine($"Json files available in directory {dir}");
                    foreach (string filePath in Directory.GetFiles(dir, "*.json") ?? new string[] { "--no files found--" })
                    {
                        Console.WriteLine(filePath);
                    }
                }
                break;

            default:
                return(false);
            }
            return(true);
        }