REORG
This commit is contained in:
parent
8d68ee380a
commit
45514010f2
3505 changed files with 154 additions and 523 deletions
42
src/Abstract/IT/Command.cs
Normal file
42
src/Abstract/IT/Command.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Abstract.IT
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A command specification (a system command),
|
||||
/// in order to reference some trusted server-side process
|
||||
/// </summary>
|
||||
public class Command
|
||||
{
|
||||
[Required]
|
||||
[JsonPropertyAttribute("path")]
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonPropertyAttribute("args")]
|
||||
public string[] Args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specific variables for this process
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonPropertyAttribute("env")]
|
||||
public string[] Environment { get; set; }
|
||||
|
||||
public virtual Process Start(string workingDir=null, bool redirectInput=false, bool redirectOutput=false)
|
||||
{
|
||||
var procStart = new ProcessStartInfo(Path, string.Join(" ",Args));
|
||||
procStart.WorkingDirectory = workingDir;
|
||||
procStart.UseShellExecute = false;
|
||||
procStart.RedirectStandardInput = true;
|
||||
procStart.RedirectStandardOutput = true;
|
||||
procStart.RedirectStandardError = false;
|
||||
return Process.Start(procStart);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue