本文整理汇总了C#中System.Diagnostics.ProcessStartInfo.SetCommand方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessStartInfo.SetCommand方法的具体用法?C# ProcessStartInfo.SetCommand怎么用?C# ProcessStartInfo.SetCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.ProcessStartInfo
的用法示例。
在下文中一共展示了ProcessStartInfo.SetCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exec
/// <exception cref="NGit.Errors.TransportException"></exception>
internal override void Exec(string commandName)
{
string ssh = SystemReader.GetInstance().Getenv("GIT_SSH");
bool putty = ssh.ToLower().Contains("plink");
IList<string> args = new AList<string>();
args.AddItem(ssh);
if (putty)
{
args.AddItem("--batch");
}
if (0 < this._enclosing.GetURI().GetPort())
{
args.AddItem(putty ? "-P" : "-p");
args.AddItem(this._enclosing.GetURI().GetPort().ToString());
}
if (this._enclosing.GetURI().GetUser() != null)
{
args.AddItem(this._enclosing.GetURI().GetUser() + "@" + this._enclosing.GetURI().
GetHost());
}
else
{
args.AddItem(this._enclosing.GetURI().GetHost());
}
args.AddItem(this._enclosing.CommandFor(commandName));
ProcessStartInfo pb = new ProcessStartInfo();
pb.SetCommand(args);
if (this._enclosing.local.Directory != null)
{
pb.EnvironmentVariables.Put(Constants.GIT_DIR_KEY, this._enclosing.local.Directory
.GetPath());
}
try
{
this.proc = pb.Start();
}
catch (IOException err)
{
throw new TransportException(this._enclosing.uri, err.Message, err);
}
}
示例2: Exec
/// <exception cref="NGit.Errors.TransportException"></exception>
public virtual SystemProcess Exec(string command, int timeout)
{
string ssh = SystemReader.GetInstance().Getenv("GIT_SSH");
bool putty = ssh.ToLower().Contains("plink");
IList<string> args = new AList<string>();
args.AddItem(ssh);
if (putty && !ssh.ToLower().Contains("tortoiseplink"))
{
args.AddItem("-batch");
}
if (0 < this._enclosing.GetURI().GetPort())
{
args.AddItem(putty ? "-P" : "-p");
args.AddItem(this._enclosing.GetURI().GetPort().ToString());
}
if (this._enclosing.GetURI().GetUser() != null)
{
args.AddItem(this._enclosing.GetURI().GetUser() + "@" + this._enclosing.GetURI().
GetHost());
}
else
{
args.AddItem(this._enclosing.GetURI().GetHost());
}
args.AddItem(command);
ProcessStartInfo pb = new ProcessStartInfo();
pb.SetCommand(args);
if (this._enclosing.local.Directory != null)
{
pb.EnvironmentVariables.Put(Constants.GIT_DIR_KEY, this._enclosing.local.Directory
.GetPath());
}
try
{
return pb.Start();
}
catch (IOException err)
{
throw new TransportException(err.Message, err);
}
}
示例3: RunInShell
public override ProcessStartInfo RunInShell(string cmd, string[] args)
{
IList<string> argv = new AList<string>(3 + args.Length);
argv.AddItem("cmd.exe");
argv.AddItem("/c");
argv.AddItem(cmd);
Sharpen.Collections.AddAll(argv, Arrays.AsList(args));
ProcessStartInfo proc = new ProcessStartInfo();
proc.SetCommand(argv);
return proc;
}