Beispiel #1
0
        public VersionCommand Command()
        {
            var commandFactory = sp.GetService <VersionCommandFactory>();
            var commandName    = VersionCommandName.FromValue(Options.Command);
            var command        = commandFactory.Create(commandName);

            return(command);
        }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            using var scope = services.CreateScope();
            try
            {
                var commandFactory = scope.ServiceProvider.GetService <VersionCommandFactory>();
                var options        = scope.ServiceProvider.GetService <IOptions <VersionToolOptions> >().Value;
                var commandName    = VersionCommandName.FromValue(options.Command);
                var command        = commandFactory.Create(commandName);
                await command.Execute(options);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Environment.ExitCode = 999;
            }
            var lifetime = scope.ServiceProvider.GetService <IHostApplicationLifetime>();

            lifetime.StopApplication();
        }