Esempio n. 1
0
        public static void Main(string[] args)
        {
            ParamOptions opts      = null;
            Parser       argParser = new Parser(conf =>
            {
                conf.HelpWriter = Console.Out;
                conf.CaseInsensitiveEnumValues = true;
                conf.CaseSensitive             = false;
            });

            argParser.ParseArguments <AllBenchOptions,
                                      CompBenchOptions, DecompBenchOptions, HashBenchOptions, BufferSizeBenchOptions>(args)
            .WithParsed <AllBenchOptions>(x => opts        = x)
            .WithParsed <CompBenchOptions>(x => opts       = x)
            .WithParsed <DecompBenchOptions>(x => opts     = x)
            .WithParsed <HashBenchOptions>(x => opts       = x)
            .WithParsed <BufferSizeBenchOptions>(x => opts = x)
            .WithNotParsed(PrintErrorAndExit);
            Debug.Assert(opts != null, $"{nameof(opts)} != null");

            switch (opts)
            {
            case AllBenchOptions _:
                BenchmarkRunner.Run <CompBench>();
                BenchmarkRunner.Run <DecompBench>();
                BenchmarkRunner.Run <HashBench>();
                BenchmarkRunner.Run <BufferSizeBench>();
                break;

            case CompBenchOptions _:
                BenchmarkRunner.Run <CompBench>();
                break;

            case DecompBenchOptions _:
                BenchmarkRunner.Run <DecompBench>();
                break;

            case HashBenchOptions _:
                BenchmarkRunner.Run <HashBench>();
                break;

            case BufferSizeBenchOptions _:
                BenchmarkRunner.Run <BufferSizeBench>();
                break;
            }
        }
Esempio n. 2
0
 public static T Cast <T>(ParamOptions opts) where T : ParamOptions
 {
     return(opts.Cast <T>());
 }