internal ProcessExecutor( CancellationToken cancellationToken, Downloader.Models.ApplicationExecRoot executable, Storage.Models.StorageEnv env) : base(cancellationToken, env) { _info = new ProcessStartInfo { ErrorDialog = false, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; var args = ReplaceWithEnvironment(executable.Args.ToString()); var command = ReplaceWithEnvironment(executable.Binary); foreach (var e in executable.Env) { var enValue = ReplaceWithEnvironment(e.Value); // FIXME: OMG! I am so sowwy((( foreach (var e1 in executable.Env) { enValue = enValue.Replace(e1.Key, e1.Value); } _info.Environment.Add(e.Key, enValue); command = command.Replace(e.Key, e.Value); args = args.Replace(e.Key, e.Value); } _info.FileName = command; _info.Arguments = args; }
internal CmdExecutor( CancellationToken cancellationToken, Downloader.Models.ApplicationExecRoot executable, Storage.Models.StorageEnv env) : base(cancellationToken, OverrideExecutable(executable), env) { }
/// <summary> /// /// </summary> /// <returns></returns> internal static Executor Get(CancellationToken cancellationToken, Downloader.Models.ApplicationExecRoot executable, Storage.Models.StorageEnv env) { return(executable.Binary switch { CmdExecutor.COMMAND_PREFIX => new CmdExecutor(cancellationToken, executable, env), _ => new ProcessExecutor(cancellationToken, executable, env), });
/// <summary> /// /// </summary> /// <param name="executable"></param> /// <returns></returns> public Task <Identity> ExecuteAsync(Storage.Models.StorageEnv storageEnv, Downloader.Models.IExecutable executable) { if (executable.Exec.Hooks?.Before != null) { return(StartTaskAsync( storageEnv, () => (_identifier.GetNext(e => e.ExecuteHookBefore), executable.Exec.Hooks?.Before), () => (_identifier.GetNext(e => e.ExecuteMain), executable.Exec), () => (_identifier.GetNext(e => e.ExecuteHookAfter), executable.Exec.Hooks?.After))); } else { return(StartTaskAsync( storageEnv, () => (_identifier.GetNext(e => e.ExecuteMain), executable.Exec), () => (_identifier.GetNext(e => e.ExecuteHookAfter), executable.Exec.Hooks?.After), null)); } }
protected Executor(CancellationToken cancellationToken, Storage.Models.StorageEnv env) { CancellationToken = cancellationToken; Environment = env; }
/// <summary> /// /// </summary> /// <param name="process"></param> /// <returns></returns> private async Task <Identity> StartTaskAsync( Storage.Models.StorageEnv storageEnv, Func <(Identity, Downloader.Models.ApplicationExecRoot)> before,