Exemplo n.º 1
0
        public async Task ExecuteCommand(AppGetOption option)
        {
            var commandDic = option.ToDictionary();

            foreach (var pair in commandDic)
            {
                SentryTarget.AddTag(pair.Key, pair.Value);
            }

            if (option.Verbose)
            {
                LogConfigurator.EnableVerboseLogging();
            }

            var commandHandler = _handlers.Single(c => c.Key == option.GetType()).Value.Value;

            if (commandHandler == null)
            {
                throw new UnknownCommandException(option);
            }

            _logger.Debug("Starting command [{0}]", option.CommandName);
            var stopwatch = Stopwatch.StartNew();
            await commandHandler.Execute(option);
            stopwatch.Stop();
            Console.WriteLine();
            _logger.Debug("Completed command [{0}]. took: {1:N}s", option.CommandName, stopwatch.Elapsed.TotalSeconds);
        }