protected override Process Execute(RedirectionMode mode, params string[] args)
        {
            var argsNew = new List <string>(args);

            argsNew.Insert(0, PythonScriptPath);
            return(base.Execute(mode, argsNew.ToArray()));
        }
Exemplo n.º 2
0
        public RedirectionSegment(IShellSegment segment, IShellSegment device, RedirectionMode mode)
        {
            Ensure.That(segment, nameof(segment)).IsNotNull();
            Ensure.That(device, nameof(device)).IsNotNull();

            this.Left   = segment;
            this.Device = device;
            this.Mode   = mode;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="algorithm">The crypto alogrithm</param>
        /// <param name="from">This source stream</param>
        /// <param name="to">The destination stream</param>
        /// <param name="mode">The crypto mode</param>
        /// <param name="chunkSize">The encryption chunk size</param>
        public CryptoDirector(ICryptoAlgorithm algorithm, Stream from, Stream to, RedirectionMode mode, uint chunkSize = 1024 * 1024)
        {
            /**     Validate required parameters    **/
            if (algorithm == null)
            {
                throw new ArgumentNullException("algorithm");
            }
            if (from == null)
            {
                throw new ArgumentNullException("from");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            /**     Initiaize private fileds **/
            _algorithm = algorithm;
            _from      = from;
            _to        = to;
            _chunkSize = chunkSize;
            _mode      = mode;
        }
        protected virtual Process Execute(RedirectionMode mode, params string[] args)
        {
            Process      p = null;
            StreamReader stdoutTempReader;
            StreamReader stderrTempReader;

            switch (Mode)
            {
            case RedirectionMode.None:
                p = ExecuteProcess(ExecutablePath, ExitHandler, WaitForExit, args);
                break;

            case RedirectionMode.UseHandlers:
                if (StdoutHandler == null || StderrHandler == null)
                {
                    throw new InvalidOperationException(
                              "With mode UseHandlers, both handlers should be assigned! \n "
                              + (StdoutHandler == null ? "StdoutHandler is not assigned\n" : "")
                              + (StderrHandler == null ? "StdoutErrHandler is not assigned\n" : ""));
                }
                p = ExecuteProcess(ExecutablePath, StdoutHandler, StderrHandler, ExitHandler, WaitForExit, args);
                break;

            case RedirectionMode.RedirectStreams:
                p            = ExecuteProcess(ExecutablePath, out stdoutTempReader, out stderrTempReader, ExitHandler, WaitForExit, args);
                StdoutReader = stdoutTempReader;
                StderrReader = stderrTempReader;
                break;

            case RedirectionMode.RedirectStdoutWithStderrHandler:
                if (StderrHandler == null)
                {
                    throw new InvalidOperationException(
                              "With mode StdoutStreamWithStderrHandler, StdErrHandler should be assigned! \n");
                }
                p            = ExecuteProcess(ExecutablePath, true, out stdoutTempReader, StderrHandler, ExitHandler, WaitForExit, args);
                StdoutReader = stdoutTempReader;
                break;

            case RedirectionMode.RedirectStderrWithStdoutHandler:
                if (StderrHandler == null)
                {
                    throw new InvalidOperationException(
                              "With mode StderrStreamWithStdoutHandler, StdoutHandler should be assigned! \n");
                }
                p            = ExecuteProcess(ExecutablePath, false, out stderrTempReader, StdoutHandler, ExitHandler, WaitForExit, args);
                StderrReader = stderrTempReader;
                break;

            case RedirectionMode.RedirectStdout:
                p            = ExecuteProcess(ExecutablePath, true, out stdoutTempReader, ExitHandler, WaitForExit, args);
                StdoutReader = stdoutTempReader;
                break;

            case RedirectionMode.RedirectStderr:
                p            = ExecuteProcess(ExecutablePath, false, out stderrTempReader, ExitHandler, WaitForExit, args);
                StderrReader = stderrTempReader;
                break;

            case RedirectionMode.StdoutHandler:
                if (StdoutHandler == null)
                {
                    throw new InvalidOperationException(
                              "With mode StdoutHandler, StdoutHandler should be assigned! \n");
                }
                p = ExecuteProcess(ExecutablePath, true, StdoutHandler, ExitHandler, WaitForExit, args);
                break;

            case RedirectionMode.StderrHandler:
                if (StderrHandler == null)
                {
                    throw new InvalidOperationException(
                              "With mode StderrHandler, StderrHandler should be assigned! \n");
                }
                p = ExecuteProcess(ExecutablePath, false, StderrHandler, ExitHandler, WaitForExit, args);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(p);
        }
Exemplo n.º 5
0
 public RedirectionLexeme(RedirectionMode mode) => this._mode = mode;