private void Initialize(string pFileName, ICommandLineArgumentEscaper pEscaper, params object[] pArguments) { if (pFileName == null) { throw new ArgumentNullException("pFileName"); } if (pFileName.Length == 0) { throw new ArgumentException("String is blank", "pFileName"); } Initialize(new FileInfo(pFileName), pEscaper, pArguments); }
private void Initialize(string file, ICommandLineArgumentEscaper escaper, params object[] args) { if (file == null) { throw new ArgumentNullException(nameof(file)); } if (file.Length == 0) { throw new ArgumentException("String is blank", nameof(file)); } Initialize(new FileInfo(file), escaper, args); }
/// <summary> /// Initializes a new instance of the <see cref="TestLib.Framework.Util.ProcessSpawnerWithCombinedAndSplitErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="file">The <see cref="FileInfo" /> carrying information about the file to execute.</param> /// <param name="escaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="args">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithCombinedAndSplitErrAndOut(FileInfo file, ICommandLineArgumentEscaper escaper, params object[] args) { m_split = new ProcessSpawnerWithSplitErrAndOut(file, escaper, args); m_combined = new ProcessSpawnerWithCombinedErrAndOut(file, escaper, args); }
/// <summary> /// Initializes a new instance of the <see cref="TestLib.Framework.Util.ProcessSpawnerWithCombinedErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="file">The <see cref="FileInfo" /> carrying information about the file to execute.</param> /// <param name="escaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="args">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithCombinedErrAndOut(FileInfo file, ICommandLineArgumentEscaper escaper, params object[] args) { Initialize(file, escaper, args); }
private void Initialize(FileInfo file, ICommandLineArgumentEscaper escaper, params object[] args) { if (file == null) { throw new ArgumentNullException(nameof(file)); } if (!file.Exists) { throw new FileNotFoundException("File not found", file.FullName); } if (args != null && args.Any()) { if (escaper == null) { throw new ArgumentNullException(nameof(escaper)); } } var startInfo = new ProcessStartInfo() { FileName = "cmd.exe", RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, UseShellExecute = false, CreateNoWindow = true, }; string arguments = string.Empty; if (args != null && args.Any()) { arguments = escaper.Escape(args); } // Needed for Windows again string quote = @""""; startInfo.Arguments = "/c " + quote + file.FullName + quote + " " + arguments + " 2>&1"; m_process = new Process() { StartInfo = startInfo, EnableRaisingEvents = true, }; m_process.OutputDataReceived += (sender, e) => { if (e.Data == null) { return; } if (m_outputSinceLastInput != null) { if (m_outputSinceLastInput.Length != 0) { m_outputSinceLastInput.AppendLine(); } m_outputSinceLastInput.Append(e.Data); } if (m_combinedOutput.Length != 0) { m_combinedOutput.AppendLine(); } m_combinedOutput.Append(e.Data); }; }
/// <summary> /// Initializes a new instance of the <see cref="TestLib.Framework.Util.ProcessSpawnerWithSplitErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="file">The name of the file to execute.</param> /// <param name="escaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="args">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithSplitErrAndOut(string file, ICommandLineArgumentEscaper escaper, params object[] args) { Initialize(file, escaper, args); }
private void Initialize(FileInfo file, ICommandLineArgumentEscaper escaper, params object[] args) { if (file == null) { throw new ArgumentNullException(nameof(file)); } if (!file.Exists) { throw new FileNotFoundException("File not found", file.FullName); } if (args != null && args.Any()) { if (escaper == null) { throw new ArgumentNullException(nameof(escaper)); } } var startInfo = new ProcessStartInfo() { FileName = file.FullName, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, UseShellExecute = false, CreateNoWindow = true, }; if (args != null && args.Any()) { startInfo.Arguments = escaper.Escape(args); } m_process = new Process() { StartInfo = startInfo, EnableRaisingEvents = true, }; m_process.OutputDataReceived += (sender, e) => { if (e.Data == null) { return; } if (m_outputSinceLastInput != null) { if (m_outputSinceLastInput.Length != 0) { m_outputSinceLastInput.AppendLine(); } m_outputSinceLastInput.Append(e.Data); } if (m_output.Length != 0) { m_output.AppendLine(); } m_output.Append(e.Data); }; m_process.ErrorDataReceived += (sender, e) => { if (e.Data == null) { return; } if (m_error.Length != 0) { m_error.AppendLine(); } m_error.Append(e.Data); }; }
/// <summary> /// Initializes a new instance of the <see cref="Test.ProcessSpawnerWithSplitErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="pFile">The <see cref="FileInfo" /> carrying information about the file to execute.</param> /// <param name="pEscaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="pArguments">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithSplitErrAndOut(FileInfo pFile, ICommandLineArgumentEscaper pEscaper, params object[] pArguments) { Initialize(pFile, pEscaper, pArguments); }
/// <summary> /// Initializes a new instance of the <see cref="Test.ProcessSpawnerWithCombinedAndSplitErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="pFile">The <see cref="FileInfo" /> carrying information about the file to execute.</param> /// <param name="pEscaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="pArguments">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithCombinedAndSplitErrAndOut(FileInfo pFile, ICommandLineArgumentEscaper pEscaper, params object[] pArguments) { m_split = new ProcessSpawnerWithSplitErrAndOut(pFile, pEscaper, pArguments); m_combined = new ProcessSpawnerWithCombinedErrAndOut(pFile, pEscaper, pArguments); }
/// <summary> /// Initializes a new instance of the <see cref="Test.ProcessSpawnerWithCombinedErrAndOut" /> class with a specified file, command line escaper, and command line arguments. /// </summary> /// <param name="pFileName">The name of the file to execute.</param> /// <param name="pEscaper">The command line escaper to produce a command line argument string from the command line arguments.</param> /// <param name="pArguments">The command line arguments to pass to the execution of the file.</param> public ProcessSpawnerWithCombinedErrAndOut(string pFileName, ICommandLineArgumentEscaper pEscaper, params object[] pArguments) { Initialize(pFileName, pEscaper, pArguments); }