Ejemplo n.º 1
0
        public void Activation()
        {
            _studio  = IoC.Get <IStudio>();
            _console = IoC.Get <IConsole>();

            var started        = Observable.FromEventPattern(this, nameof(TargetStarted)).Select(e => true);
            var stopped        = Observable.FromEventPattern(this, nameof(TargetStopped)).Select(e => false);
            var sessionStarted = Observable.FromEventPattern(this, nameof(DebugSessionStarted)).Select(e => true);
            var sessionEnded   = Observable.FromEventPattern(this, nameof(DebugSessionEnded)).Select(e => false);

            var hasSession = sessionStarted.Merge(sessionEnded).StartWith(false);

            var isRunning = hasSession.Merge(started).Merge(stopped).StartWith(false);

            var canRun = _studio.OnSolutionLoaded().CombineLatest(isRunning, hasSession, _studio.OnCurrentTaskChanged(), (loaded, running, session, hasTask) =>
            {
                return(loaded && !running && (!hasTask || (hasTask && session)));
            });

            var canPause = _studio.OnSolutionLoaded().CombineLatest(isRunning, (loaded, running) => loaded && running);

            var canStop = _studio.OnSolutionLoaded().CombineLatest(sessionStarted.Merge(sessionEnded), (loaded, sessionActive) => loaded && SessionActive);

            var canStep = canStop.CombineLatest(isRunning, (stop, running) => stop && !running);

            CanStart = canRun.StartWith(false);

            CanPause = canPause.StartWith(false);

            CanStop = canStop.StartWith(false);

            CanStep = canStep.StartWith(false);

            _studio.OnSolutionChanged.Subscribe(_ => LoadBreakpoints());
        }
Ejemplo n.º 2
0
 public static IObservable <bool> CanRunTask(this IStudio studio) => studio.OnSolutionLoaded().CombineLatest(studio.OnCurrentTaskChanged(), (loaded, running) => loaded & !running);