Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // coming from file
            ExecutionConf execConf = new ExecutionConf()
            {
                RunType      = RunType.Release,
                NumOfThreads = 10
            };

            var arguments = new string[]
            {
                "--AppName=\"Different name\"",
                "--ExecutionConf.NumOfThreads=3"
            };

            // idea is to use AppConfig default values
            // then map over config from file (execConf)
            // and finally map over arguments
            // and then get a resulting configuration

            var config = new Configuration <AppConfig>();

            config.ApplySource(execConf);
            config.ApplyArguments(arguments);


            Console.WriteLine(config.Instance.AppName);
            Console.WriteLine(config.Instance.AppVersion);
            Console.WriteLine(config.Instance.ExecutionConf.RunType.ToString());
            Console.WriteLine(config.Instance.ExecutionConf.NumOfThreads);

            Console.ReadLine();
        }
Exemplo n.º 2
0
 public AppConfig() // define defaults
 {
     AppName       = "Test App";
     AppVersion    = new Version(1, 1, 1);
     ExecutionConf = new ExecutionConf()
     {
         RunType      = RunType.Debug,
         NumOfThreads = 4
     };
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // coming from file
            ExecutionConf execConf = new ExecutionConf()
            {
                RunType      = RunType.Release,
                NumOfThreads = 10
            };

            var arguments = new string[]
            {
                "--AppName=\"Different name\"",
                "--ExecutionConf.NumOfThreads=3"
            };

            // idea is to use AppConfig default falues
            // then map over config from file (execConf)
            // and finally map over arguments
            // and then get a resulting configuration

            Console.WriteLine("Hello World!");
        }