예제 #1
0
 private static TIShell CreateFrom(
     Shell <TIShell> old,
     string shell = null,
     IEnumerable <KeyValuePair <string, string> > environmentVariables = null,
     IEnumerable <string> standardInputs = null,
     IEnumerable <Action <string> > standardOutputHandlers     = null,
     IEnumerable <Action <string> > standardErrorHandlers      = null,
     Func <string, string, Task <string> > inputRequestHandler = null,
     Encoding standardOutputEncoding = null,
     Encoding standardErrorEncoding  = null,
     ObservableCommandEvent observableCommandEvent      = null,
     IEnumerable <CancellationToken> cancellationTokens = null,
     string commandPrefix = null,
     Action <ProcessStartInfo> startInfoTransform = null,
     bool?throws = null) =>
 (TIShell)old.Create().Initialize(
     shell ?? old._shell,
     environmentVariables ?? old._environmentVariables,
     standardInputs ?? old._standardInputs,
     standardOutputHandlers ?? old._standardOutputHandlers,
     standardErrorHandlers ?? old._standardErrorHandlers,
     inputRequestHandler ?? old._inputRequestHandler,
     standardOutputEncoding ?? old._standardOutputEncoding,
     standardErrorEncoding ?? old._standardErrorEncoding,
     observableCommandEvent ?? old._observableCommandEvent,
     cancellationTokens ?? old._cancellationTokens,
     commandPrefix ?? old._commandPrefix,
     startInfoTransform ?? old._startInfoTransform,
     throws ?? old._throws
     );
예제 #2
0
        private IShell Initialize(
            string shell,
            IEnumerable <KeyValuePair <string, string> > environmentVariables,
            IEnumerable <string> standardInputs,
            IEnumerable <Action <string> > standardOutputHandlers,
            IEnumerable <Action <string> > standardErrorHandlers,
            Func <string, string, Task <string> > inputRequestHandler,
            Encoding standardOutputEncoding,
            Encoding standardErrorEncoding,
            ObservableCommandEvent observableCommandEvent,
            IEnumerable <CancellationToken> cancellationTokens,
            string commandPrefix,
            Action <ProcessStartInfo> startInfoTransform,
            bool?throws)
        {
            _shell = shell ?? throw new InvalidOperationException("This shell definition does not define a shell.");;

            _environmentVariables = environmentVariables ?? new Dictionary <string, string>();

            _standardInputs         = standardInputs ?? new List <string>();
            _standardOutputHandlers = standardOutputHandlers ?? new List <Action <string> >();
            _standardErrorHandlers  = standardErrorHandlers ?? new List <Action <string> >();
            _inputRequestHandler    = inputRequestHandler;
            _standardOutputEncoding = standardOutputEncoding;
            _standardErrorEncoding  = standardErrorEncoding;

            _observableCommandEvent = observableCommandEvent ?? new ObservableCommandEvent();

            _cancellationTokens = cancellationTokens ?? new List <CancellationToken>();

            _commandPrefix = commandPrefix;

            _startInfoTransform = startInfoTransform;

            _throws = throws ?? true;

            return(this);
        }
예제 #3
0
 void ObservableCommandHandler (object context)
 {
   ObservableCommandEvent?.Invoke (this, new TObservableCommandEventArgs (context));
 }