예제 #1
0
        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;
        }
예제 #2
0
 internal CmdExecutor(
     CancellationToken cancellationToken,
     Downloader.Models.ApplicationExecRoot executable,
     Storage.Models.StorageEnv env)
     : base(cancellationToken, OverrideExecutable(executable), env)
 {
 }
예제 #3
0
 /// <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),
     });
예제 #4
0
 /// <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));
     }
 }
예제 #5
0
 protected Executor(CancellationToken cancellationToken, Storage.Models.StorageEnv env)
 {
     CancellationToken = cancellationToken;
     Environment       = env;
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="process"></param>
 /// <returns></returns>
 private async Task <Identity> StartTaskAsync(
     Storage.Models.StorageEnv storageEnv,
     Func <(Identity, Downloader.Models.ApplicationExecRoot)> before,