/// <summary>
        /// Creates an instance of the REPL engine ViewModel.
        /// </summary>
        /// <param name="replState">Reactive extensions stream of the REPL engine state.</param>
        /// <param name="replOutput">Reactive extensions stream of the REPL engine output.</param>
        /// <param name="replError">Reactive extensions stream of the REPL engine errors.</param>
        /// <param name="workingDirectory">Reactive extensions stream of the REPL engine working directory.</param>
        /// <param name="processService">Handles starting windows processes.</param>
        public ReplEngineViewModel(IObservable<State> replState,
            IObservable<ReplLineViewModel> replOutput,
            IObservable<ReplLineViewModel> replError,
            string workingDirectory,
            IProcessService processService)
        {
            _workingDirectory = workingDirectory;
            _processService = processService;
            _state = Core.State.Unknown;
            _output = new ObservableCollection<ReplLineViewModel>();

            _reset = new Subject<Unit>();
            _execute = new Subject<string>();

            ClearCommand = new ReplRelayCommand(Clear, CanClear);
            ResetCommand = new ReplRelayCommand(ResetImpl, CanReset);
            ExecuteCommand = new ReplRelayCommand<string>(ExecuteImpl, CanExecute);
            OpenWorkingFolderCommand = new ReplRelayCommand(OpenWorkingFolder);

            _disposable = new CompositeDisposable
            {
                Disposable.Create(() =>
                                  {
                                        ClearCommand = null;
                                        ResetCommand = null;
                                        ExecuteCommand = null;
                                  }),
                _reset,
                _execute,
                replState.Subscribe(UpdateState),
                replOutput.Where(x => x.Value != Prompt)
                    .Subscribe(x =>
                    {
                        _output.Add(x);
                        CommandManager.InvalidateRequerySuggested();
                    }),
                replError.Where(x => x.Value != Prompt)
                    .Subscribe(x =>
                    {
                        _output.Add(x);
                        CommandManager.InvalidateRequerySuggested();
                    })
            };
        }
Пример #2
0
        /// <summary>
        ///     Creates an instance of the REPL engine ViewModel.
        /// </summary>
        /// <param name="replState">Reactive extensions stream of the REPL engine state.</param>
        /// <param name="replOutput">Reactive extensions stream of the REPL engine output.</param>
        /// <param name="replError">Reactive extensions stream of the REPL engine errors.</param>
        /// <param name="workingDirectory">Reactive extensions stream of the REPL engine working directory.</param>
        /// <param name="processService">Handles starting windows processes.</param>
        public ReplEngineViewModel(IObservable <State> replState,
                                   IObservable <ReplLineViewModel> replOutput,
                                   IObservable <ReplLineViewModel> replError,
                                   string workingDirectory,
                                   IProcessService processService)
        {
            WorkingDirectory = workingDirectory;
            _processService  = processService;
            _state           = Core.State.Unknown;
            _output          = new ObservableCollection <ReplLineViewModel>();

            _reset   = new Subject <Unit>();
            _execute = new Subject <string>();

            ClearCommand             = new ReplRelayCommand(Clear, CanClear);
            ResetCommand             = new ReplRelayCommand(ResetImpl, CanReset);
            ExecuteCommand           = new ReplRelayCommand <string>(ExecuteImpl, CanExecute);
            OpenWorkingFolderCommand = new ReplRelayCommand(OpenWorkingFolder);

            _disposable = new CompositeDisposable
            {
                Disposable.Create(() =>
                {
                    ClearCommand   = null;
                    ResetCommand   = null;
                    ExecuteCommand = null;
                }),
                _reset,
                _execute,
                replState.Subscribe(UpdateState),
                replOutput.Where(x => x.Value != Prompt)
                .Subscribe(x =>
                {
                    _output.Add(x);
                    CommandManager.InvalidateRequerySuggested();
                }),
                replError.Where(x => x.Value != Prompt)
                .Subscribe(x =>
                {
                    _output.Add(x);
                    CommandManager.InvalidateRequerySuggested();
                })
            };
        }