示例#1
0
        public void StartApplication(string applicationName  = null, string commandName = null,
                                     List <string> arguments = null, string pipeline    = null)
        {
            applicationName = applicationName ?? Application.Default;
            commandName     = commandName ?? Command.Default;
            arguments       = (arguments ?? Enumerable.Empty <string>()).Select(a => $"\"{a}\"").ToList();
            pipeline        = !string.IsNullOrEmpty(pipeline) ? $"\"{pipeline ?? string.Empty}\"" : string.Empty;

            var application      = _applicationRepository.GetApplication(applicationName);
            var command          = _applicationRepository.GetCommand(applicationName, commandName);
            var commandArguments = (command?.Arguments ?? new List <string>())
                                   .Select(a => _templateProcessor.Transform(a, TemplateModel.PipelineAndArgs(pipeline, arguments)))
                                   .Where(a => !string.IsNullOrEmpty(a))
                                   .ToList();

            if (application == null)
            {
                throw new ArgumentException($"Application '{applicationName}' is not configured");
            }
            if (command == null)
            {
                throw new ArgumentException($"Command '{commandName}' in application '{applicationName}' is not configured");
            }

            var processInfo = GetProcessInfo(application, command, commandArguments);

            _processLauncher.Launch(processInfo, command.WaitForExit);
        }