Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5035 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
7 changed files with 2 additions and 215 deletions
@ -1,41 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop.Util; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Process runner interface.
|
|
||||||
/// </summary>
|
|
||||||
public interface IProcessRunner |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Triggered when a line of text is read from the standard output.
|
|
||||||
/// </summary>
|
|
||||||
event LineReceivedEventHandler OutputLineReceived; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggered when the process has exited.
|
|
||||||
/// </summary>
|
|
||||||
event EventHandler ProcessExited; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Starts the process.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command">The process filename.</param>
|
|
||||||
/// <param name="arguments">The command line arguments to
|
|
||||||
/// pass to the command.</param>
|
|
||||||
void Start(string command, string arguments); |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Kills the running process.
|
|
||||||
/// </summary>
|
|
||||||
void Kill(); |
|
||||||
} |
|
||||||
} |
|
@ -1,16 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop.Util; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonProcessRunner : ProcessRunner, IProcessRunner |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
@ -1,132 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using ICSharpCode.PythonBinding; |
|
||||||
using ICSharpCode.SharpDevelop.Util; |
|
||||||
|
|
||||||
namespace PythonBinding.Tests.Utils |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Dummy IProcessRunner class.
|
|
||||||
/// </summary>
|
|
||||||
public class MockProcessRunner : IProcessRunner |
|
||||||
{ |
|
||||||
string commandLine = String.Empty; |
|
||||||
string outputText; |
|
||||||
bool killCalled; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggered when a line of text is read from the standard output.
|
|
||||||
/// </summary>
|
|
||||||
public event LineReceivedEventHandler OutputLineReceived; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggered when the process has exited.
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler ProcessExited; |
|
||||||
|
|
||||||
public MockProcessRunner() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Starts the process.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command">The process filename.</param>
|
|
||||||
/// <param name="arguments">The command line arguments to
|
|
||||||
/// pass to the command.</param>
|
|
||||||
public void Start(string command, string arguments) |
|
||||||
{ |
|
||||||
commandLine = String.Concat(command, " ", arguments); |
|
||||||
if (outputText != null) { |
|
||||||
OnOutputLineReceived(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Kills the running process.
|
|
||||||
/// </summary>
|
|
||||||
public void Kill() |
|
||||||
{ |
|
||||||
killCalled = true; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the full command line used with the process runner.
|
|
||||||
/// </summary>
|
|
||||||
public string CommandLine { |
|
||||||
get { |
|
||||||
return commandLine; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The string will be sent to any OutputLineReceived event
|
|
||||||
/// handler when the Start method is called.
|
|
||||||
/// </summary>
|
|
||||||
public string OutputText { |
|
||||||
set { |
|
||||||
outputText = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raises the ProcessExited event.
|
|
||||||
/// </summary>
|
|
||||||
public void RaiseExitEvent() |
|
||||||
{ |
|
||||||
OnProcessExited(new EventArgs()); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates whether the Kill method was called.
|
|
||||||
/// </summary>
|
|
||||||
public bool KillCalled { |
|
||||||
get { |
|
||||||
return killCalled; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raises the ProcessExited event.
|
|
||||||
/// </summary>
|
|
||||||
void OnProcessExited(EventArgs e) |
|
||||||
{ |
|
||||||
if (ProcessExited != null) { |
|
||||||
ProcessExited(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raises the OutputLineReceived event.
|
|
||||||
/// </summary>
|
|
||||||
void OnOutputLineReceived(LineReceivedEventArgs e) |
|
||||||
{ |
|
||||||
if (OutputLineReceived != null) { |
|
||||||
OutputLineReceived(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raises an event for each line in the output text.
|
|
||||||
/// </summary>
|
|
||||||
void OnOutputLineReceived() |
|
||||||
{ |
|
||||||
using (StringReader reader = new StringReader(outputText)) { |
|
||||||
string line; |
|
||||||
do { |
|
||||||
line = reader.ReadLine(); |
|
||||||
if (line != null) { |
|
||||||
OnOutputLineReceived(new LineReceivedEventArgs(line)); |
|
||||||
} |
|
||||||
} while (line != null); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue