15 changed files with 190 additions and 221 deletions
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public class ScriptingCommandLineBuilder |
||||
{ |
||||
StringBuilder commandLine = new StringBuilder(); |
||||
|
||||
public ScriptingCommandLineBuilder() |
||||
{ |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return commandLine.ToString().TrimEnd(); |
||||
} |
||||
|
||||
public void AppendBooleanOptionIfTrue(string option, bool flag) |
||||
{ |
||||
if (flag) { |
||||
AppendOption(option); |
||||
} |
||||
} |
||||
|
||||
public void AppendOption(string option) |
||||
{ |
||||
commandLine.Append(option + " "); |
||||
} |
||||
|
||||
public void AppendQuotedStringIfNotEmpty(string option) |
||||
{ |
||||
if (!String.IsNullOrEmpty(option)) { |
||||
AppendQuotedString(option); |
||||
} |
||||
} |
||||
|
||||
public void AppendQuotedString(string option) |
||||
{ |
||||
string quotedOption = String.Format("\"{0}\"", option); |
||||
AppendOption(quotedOption); |
||||
} |
||||
|
||||
public void AppendStringIfNotEmpty(string option) |
||||
{ |
||||
if (!String.IsNullOrEmpty(option)) { |
||||
AppendOption(option); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public abstract class ScriptingConsoleApplication |
||||
{ |
||||
public ScriptingConsoleApplication() |
||||
{ |
||||
WorkingDirectory = String.Empty; |
||||
ScriptFileName = String.Empty; |
||||
ScriptCommandLineArguments = String.Empty; |
||||
} |
||||
|
||||
public bool Debug { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Console application filename.
|
||||
/// </summary>
|
||||
public virtual string FileName { get; set; } |
||||
|
||||
public string WorkingDirectory { get; set; } |
||||
|
||||
public string ScriptFileName { get; set; } |
||||
|
||||
public string ScriptCommandLineArguments { get; set; } |
||||
|
||||
public ProcessStartInfo GetProcessStartInfo() |
||||
{ |
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(); |
||||
processStartInfo.FileName = FileName; |
||||
processStartInfo.Arguments = GetArguments(); |
||||
processStartInfo.WorkingDirectory = WorkingDirectory; |
||||
return processStartInfo; |
||||
} |
||||
|
||||
public string GetArguments() |
||||
{ |
||||
ScriptingCommandLineBuilder commandLine = new ScriptingCommandLineBuilder(); |
||||
AddArguments(commandLine); |
||||
return commandLine.ToString(); |
||||
} |
||||
|
||||
protected virtual void AddArguments(ScriptingCommandLineBuilder commandLine) |
||||
{ |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue