public override bool TryInvoke(InvokeBinder binder, object[] args, out object result) { if (!commands.Any()) { result = null; return true; } var runOptions = new RunOptions(this); result = Runner.Run(runOptions); return true; }
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result) { var names = binder.CallInfo.ArgumentNames; var numberOfArguments = binder.CallInfo.ArgumentCount; var numberOfNames = names.Count; var allNames = Enumerable.Repeat<string>(null, numberOfArguments - numberOfNames).Concat(names); arguments.AddRange(allNames.Zip(args, (flag, value) => new Argument(flag, value))); var runOptions = new RunOptions(this); result = Runner.Run(runOptions); return true; }
public string Run(RunOptions runOptions) { var process = new Process { StartInfo = { FileName = runOptions.Command, Arguments = runOptions.Arguments, UseShellExecute = false, RedirectStandardOutput = true } }; process.Start(); var output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); return output; }
public string Run(RunOptions runOptions) { var process = new Process { StartInfo = { FileName = runOptions.Command, Arguments = runOptions.Arguments, UseShellExecute = false, RedirectStandardOutput = true } }; process.Start(); var output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); return(output); }