Beispiel #1
0
        public Worker(ILogger <Worker> logger, IHostApplicationLifetime hostApplicationLifetime, T3dWriter t3DWriter, IOptions <ArgsConfig> options)
        {
            _logger = logger;
            _hostApplicationLifetime = hostApplicationLifetime;
            _t3DWriter = t3DWriter;

            _args = options.Value;
        }
Beispiel #2
0
        public void TestParsingDifferentValues()
        {
            ArgsConfig args = Parser <ArgsConfig> .Parse(new[] { "2", "3", "4", "5", "true" });

            Assert.IsTrue(args.IntArg == 2);
            Assert.IsTrue(args.FloatArg == 3f);
            Assert.IsTrue(args.DecimalArg == 4M);
            Assert.IsTrue(args.StringArg == "5");
            Assert.IsTrue(args.BoolArg == true);
        }
Beispiel #3
0
        public void TestBooleanAtTheEnd()
        {
            ArgsConfig args = Parser <ArgsConfig> .Parse(new[]
            {
                "-IntArg", "5",
                "-BoolArg"
            });

            Assert.IsTrue(args.IntArg == 5);
            Assert.IsTrue(args.BoolArg == true);
        }
Beispiel #4
0
        public void TestWrongAssignment()
        {
            bool exceptionThrown = false;

            try
            {
                ArgsConfig args = Parser <ArgsConfig> .Parse(new[] { "string" });
            }
            catch (Exception e)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
Beispiel #5
0
        public void TestUnknownArgument()
        {
            bool exceptionThrown = false;

            try
            {
                ArgsConfig args = Parser <ArgsConfig> .Parse(new[] { "-SomeArg", "value" });
            }
            catch (Exception e)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
Beispiel #6
0
        public void TestNamedArguments()
        {
            ArgsConfig args = Parser <ArgsConfig> .Parse(new[]
            {
                "-BoolArg", "true",
                "-StringArg", "2",
                "-DecimalArg", "3",
                "-FloatArg", "4",
                "-IntArg", "5"
            });

            Assert.IsTrue(args.IntArg == 5);
            Assert.IsTrue(args.FloatArg == 4f);
            Assert.IsTrue(args.DecimalArg == 3M);
            Assert.IsTrue(args.StringArg == "2");
            Assert.IsTrue(args.BoolArg == true);
        }
Beispiel #7
0
 /// <summary>
 /// Run only config update
 /// </summary>
 /// <param name="args">Command line arguments</param>
 /// <returns>Exit code</returns>
 static int RunConfig(ArgsConfig args)
 {
     ApplyCommonArgs(args);
     try
     {
         if (args.Register)
         {
             RegistryUtil.RegisterApp();
         }
         if (args.Unregister)
         {
             RegistryUtil.UnRegisterApp();
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex.Message + "\n" + Resources.str_message_run_as_admin);
         return(1);
     }
     return(0);
 }
Beispiel #8
0
 public T3dWriter(ILogger <T3dWriter> logger, ObjReader objReader, IOptions <ArgsConfig> options)
 {
     _logger    = logger;
     _objReader = objReader;
     _args      = options.Value;
 }