public string Transform(string template, TemplateModel model = null) { if (!string.IsNullOrWhiteSpace(template)) { model = model ?? new TemplateModel(); model.AddRange(TemplateModel.Default(_globalContext, _sessionContext)); model.AddRange(TemplateModel.Dictionary(_systemVariable.GetVariables())); foreach (var variable in model) { template = template.Replace(variable.Name, variable.Value); } } return(template); }
private ProcessStartInfo GetProcessInfo(Application application, Command command, List <string> arguments) { var processInfo = new ProcessStartInfo { FileName = application.Executable, Arguments = string.Join(" ", arguments), UseShellExecute = command.UseShellExecute, CreateNoWindow = command.NoWindow }; if (command.ResetVariables) { processInfo.Environment.Clear(); } if (command.DeleteVariables?.Any() == true) { foreach (var variableName in command.DeleteVariables) { processInfo.Environment.Remove(variableName); } } if (command.RereadCurrentVariables || command.RereadMachineVariables || command.RereadUserVariables) { if (command.RereadCurrentVariables) { AppendProcessVariables(processInfo, _systemVariable.GetVariables()); } if (command.RereadMachineVariables) { AppendProcessVariables(processInfo, _systemVariable.GetVariables(EnvironmentVariableTarget.Machine)); } if (command.RereadUserVariables) { AppendProcessVariables(processInfo, _systemVariable.GetVariables(EnvironmentVariableTarget.User)); } } return(processInfo); }