Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchViewModel"/> class.
        /// </summary>
        /// <param name="booksService">The books service.</param>
        /// <param name="delayService">The delay service.</param>
        public SearchViewModel(IBooksService booksService, IDelayService delayService)
        {
            this.booksService = booksService;
            this.delayService = delayService;

            this.Filtered = new ObservableServiceCollection <BookDto, BookFilter, IBooksService>(this.booksService);
        }
Пример #2
0
        public static Parser <IAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            if (indentLevel < 0)
            {
                throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel");
            }

            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return(BreakActionParser.GetParser(delayService, speechService)
                   .Or <IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService))
                   .Or <IAction>(PrepareActionParser.GetParser(delayService, speechService))
                   .Or <IAction>(SayActionParser.GetParser(speechService))
                   .Or <IAction>(WaitActionParser.GetParser(delayService))
                   .Or <IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                   .Or <IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                   .Or <IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)));
        }
        // parses any matcher with an action. e.g. "before: ..." or "after sets 3..2..8: ..."
        // returns a matcher with action, where all specified actions are enclosed in a single sequence action
        private static Parser <MatcherWithAction> GetMatcherWithActionParser(
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            var beforeSetNameParser = GetEventMatcherName(EventMatcherPreposition.Before, EventMatcherNoun.Set);
            var afterSetNameParser  = GetEventMatcherName(EventMatcherPreposition.After, EventMatcherNoun.Set);
            var beforeRepNameParser = GetEventMatcherName(EventMatcherPreposition.Before, EventMatcherNoun.Rep);
            var duringRepNameParser = GetEventMatcherName(EventMatcherPreposition.During, EventMatcherNoun.Rep);
            var afterRepNameParser  = GetEventMatcherName(EventMatcherPreposition.After, EventMatcherNoun.Rep);

            return(GetTypedEventMatcherWithActionParser <BeforeExerciseEvent>(GetEventMatcherName(EventMatcherPreposition.Before), audioService, delayService, loggerService, speechService)
                   .Or(GetTypedEventMatcherWithActionParser <AfterExerciseEvent>(GetEventMatcherName(EventMatcherPreposition.After), audioService, delayService, loggerService, speechService))
                   .Or(GetTypedEventMatcherWithActionParser <BeforeSetEvent>(beforeSetNameParser, audioService, delayService, loggerService, speechService))
                   .Or(GetTypedEventMatcherWithActionParser <AfterSetEvent>(afterSetNameParser, audioService, delayService, loggerService, speechService))
                   .Or(GetTypedEventMatcherWithActionParser <BeforeRepetitionEvent>(beforeRepNameParser, audioService, delayService, loggerService, speechService))
                   .Or(GetTypedEventMatcherWithActionParser <DuringRepetitionEvent>(duringRepNameParser, audioService, delayService, loggerService, speechService))
                   .Or(GetTypedEventMatcherWithActionParser <AfterRepetitionEvent>(afterRepNameParser, audioService, delayService, loggerService, speechService))
                   .Or(GetNumberedEventMatcherWithActionParser <BeforeSetEvent>(beforeSetNameParser, ec => ec.CurrentSet, ec => 1, ec => ec.CurrentExercise.SetCount, audioService, delayService, loggerService, speechService))
                   .Or(GetNumberedEventMatcherWithActionParser <AfterSetEvent>(afterSetNameParser, ec => ec.CurrentSet, ec => 1, ec => ec.CurrentExercise.SetCount, audioService, delayService, loggerService, speechService))
                   .Or(GetNumberedEventMatcherWithActionParser <BeforeRepetitionEvent>(beforeRepNameParser, ec => ec.CurrentRepetition, ec => 1, ec => ec.CurrentExercise.RepetitionCount, audioService, delayService, loggerService, speechService))
                   .Or(GetNumberedEventMatcherWithActionParser <DuringRepetitionEvent>(duringRepNameParser, ec => ec.CurrentRepetition, ec => 1, ec => ec.CurrentExercise.RepetitionCount, audioService, delayService, loggerService, speechService))
                   .Or(GetNumberedEventMatcherWithActionParser <AfterRepetitionEvent>(afterRepNameParser, ec => ec.CurrentRepetition, ec => 1, ec => ec.CurrentExercise.RepetitionCount, audioService, delayService, loggerService, speechService)));
        }
Пример #4
0
        public static Parser<IAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            if (indentLevel < 0)
            {
                throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel");
            }

            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return BreakActionParser.GetParser(delayService, speechService)
                .Or<IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService))
                .Or<IAction>(PrepareActionParser.GetParser(delayService, speechService))
                .Or<IAction>(SayActionParser.GetParser(speechService))
                .Or<IAction>(WaitActionParser.GetParser(delayService))
                .Or<IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                .Or<IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                .Or<IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService));
        }
Пример #5
0
 public MetronomeActionBuilder()
 {
     this.ticks         = new List <MetronomeTick>();
     this.audioService  = new AudioServiceMock(MockBehavior.Loose);
     this.delayService  = new DelayServiceMock(MockBehavior.Loose);
     this.loggerService = new LoggerServiceMock(MockBehavior.Loose);
 }
        public static Parser <Exercise> GetParser(
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return
                (from name in HeadingParser.GetParser(2)
                 from _ in VerticalSeparationParser.Parser
                 from setAndRepetitionCount in setAndRepetitionCountParser
                 from __ in VerticalSeparationParser.Parser
                 from matchersWithActions in GetMatchersWithActionsParser(audioService, delayService, loggerService, speechService).Optional()
                 select new Exercise(
                     loggerService,
                     speechService,
                     name,
                     setAndRepetitionCount.Item1,
                     setAndRepetitionCount.Item2,
                     matchersWithActions.GetOrElse(Enumerable.Empty <MatcherWithAction>())));
        }
Пример #7
0
        /// <summary>
        /// For testing purposes only.
        /// </summary>
        internal SymbolSearchService(
            Workspace workspace,
            IPackageInstallerService installerService,
            IRemoteControlService remoteControlService,
            ILogService logService,
            IDelayService delayService,
            IIOService ioService,
            IPatchService patchService,
            IDatabaseFactoryService databaseFactoryService,
            string localSettingsDirectory,
            Func<Exception, bool> reportAndSwallowException,
            CancellationTokenSource cancellationTokenSource)
        {
            if (remoteControlService == null)
            {
                // If we can't access the file update service, then there's nothing we can do.
                return;
            }

            _workspace = workspace;
            _installerService = installerService;
            _delayService = delayService;
            _ioService = ioService;
            _logService = logService;
            _remoteControlService = remoteControlService;
            _patchService = patchService;
            _databaseFactoryService = databaseFactoryService;
            _localSettingsDirectory = localSettingsDirectory;
            _reportAndSwallowException = reportAndSwallowException;

            _cancellationTokenSource = cancellationTokenSource;
            _cancellationToken = _cancellationTokenSource.Token;
        }
Пример #8
0
 // parses any number of matchers with their associated action
 private static Parser <IEnumerable <MatcherWithAction> > GetMatchersWithActionsParser(
     IAudioService audioService,
     IDelayService delayService,
     ISpeechService speechService) =>
 GetMatcherWithActionParser(audioService, delayService, speechService)
 .DelimitedBy(NewLineParser.Parser.Token(HorizontalWhitespaceParser.Parser)
              .AtLeastOnce());
 public MetronomeActionBuilder()
 {
     this.ticks = new List<MetronomeTick>();
     this.audioService = new AudioServiceMock(MockBehavior.Loose);
     this.delayService = new DelayServiceMock(MockBehavior.Loose);
     this.loggerService = new LoggerServiceMock(MockBehavior.Loose);
 }
Пример #10
0
        public static Parser <DoNotAwaitAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            if (indentLevel < 0)
            {
                throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel");
            }

            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return
                (from _ in Parse.IgnoreCase("don't")
                 from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from ___ in Parse.IgnoreCase("wait:")
                 from ____ in VerticalSeparationParser.Parser.AtLeastOnce()
                 from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService)
                 let child = new SequenceAction(actions)
                             select new DoNotAwaitAction(
                     loggerService,
                     child));
        }
        public static Parser<DoNotAwaitAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            if (indentLevel < 0)
            {
                throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel");
            }

            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return
                from _ in Parse.IgnoreCase("don't")
                from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from ___ in Parse.IgnoreCase("wait:")
                from ____ in VerticalSeparationParser.Parser.AtLeastOnce()
                from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService)
                let child = new SequenceAction(actions)
                select new DoNotAwaitAction(
                    loggerService,
                    child);
        }
Пример #12
0
        public WaitAction(IDelayService delayService, TimeSpan delay)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentCondition(delay >= TimeSpan.Zero, "delay must be greater than or equal to zero.", nameof(delay));

            this.delayService = delayService;
            this.delay = delay;
        }
Пример #13
0
        public WaitAction(IDelayService delayService, TimeSpan delay)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentCondition(delay >= TimeSpan.Zero, "delay must be greater than or equal to zero.", nameof(delay));

            this.delayService = delayService;
            this.delay        = delay;
        }
Пример #14
0
        public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));
            Ensure.ArgumentNotNull(promptSpeechText, nameof(promptSpeechText));
            Ensure.ArgumentCondition(duration >= TimeSpan.Zero, "duration must be greater than or equal to zero.", nameof(duration));

            this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText));
        }
Пример #15
0
 public UpdateDelayStatusModelDecorator(
     [NotNull] IDelayService decoratee,
     [NotNull] IStatusFullModel statusModel)
 {
     Guard.NotNull(decoratee, nameof(decoratee));
     Guard.NotNull(statusModel, nameof(statusModel));
     this.decoratee   = decoratee;
     this.statusModel = statusModel;
 }
Пример #16
0
        public MetronomeAction(IAudioService audioService, IDelayService delayService, IEnumerable <MetronomeTick> ticks)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(ticks, nameof(ticks));

            this.ticks       = ticks.ToImmutableList();
            this.innerAction = new SequenceAction(GetInnerActions(audioService, delayService, this.ticks));
        }
        public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));
            Ensure.ArgumentNotNull(promptSpeechText, nameof(promptSpeechText));
            Ensure.ArgumentCondition(duration >= TimeSpan.Zero, "duration must be greater than or equal to zero.", nameof(duration));

            this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText));
        }
        public MetronomeAction(IAudioService audioService, IDelayService delayService, ILoggerService loggerService, IEnumerable<MetronomeTick> ticks)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            ticks.AssertNotNull(nameof(ticks));

            this.ticks = ticks.ToImmutableList();
            this.innerAction = new SequenceAction(GetInnerActions(audioService, delayService, loggerService, this.ticks));
        }
Пример #19
0
        public ServiceFactory(IOrderService orderService, IDelayService delayService, IEventHistoryService eventHistory, ILocationHistoryService locationHistoryService, IVechicleService vechicleService, IDriverService driverService)

        {
            OrderService           = orderService;
            DelayService           = delayService;
            EventHistoryService    = eventHistory;
            LocationHistoryService = locationHistoryService;
            VechicleService        = vechicleService;
            DriverService          = driverService;
        }
Пример #20
0
        public MetronomeAction(IAudioService audioService, IDelayService delayService, ILoggerService loggerService, IEnumerable <MetronomeTick> ticks)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            ticks.AssertNotNull(nameof(ticks));

            this.ticks       = ticks.ToImmutableList();
            this.innerAction = new SequenceAction(GetInnerActions(audioService, delayService, loggerService, this.ticks));
        }
Пример #21
0
        public WaitAction(IDelayService delayService, TimeSpan delay)
        {
            delayService.AssertNotNull(nameof(delayService));

            if (delay < TimeSpan.Zero)
            {
                throw new ArgumentException("delay must be greater than or equal to zero.", "delay");
            }

            this.delayService = delayService;
            this.delay        = delay;
        }
Пример #22
0
        public static Parser <WaitAction> GetParser(IDelayService delayService)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));

            return
                (from _ in Parse.IgnoreCase("wait")
                 from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from ___ in Parse.IgnoreCase("for")
                 from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from duration in TimeSpanParser.Parser
                 select new WaitAction(delayService, duration));
        }
Пример #23
0
        public WaitAction(IDelayService delayService, TimeSpan delay)
        {
            delayService.AssertNotNull(nameof(delayService));

            if (delay < TimeSpan.Zero)
            {
                throw new ArgumentException("delay must be greater than or equal to zero.", "delay");
            }

            this.delayService = delayService;
            this.delay = delay;
        }
Пример #24
0
        public static Parser<WaitAction> GetParser(IDelayService delayService)
        {
            Ensure.ArgumentNotNull(delayService, nameof(delayService));

            return
                from _ in Parse.IgnoreCase("wait")
                from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from ___ in Parse.IgnoreCase("for")
                from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from duration in TimeSpanParser.Parser
                select new WaitAction(delayService, duration);
        }
Пример #25
0
        public static IResult <ExercisePrograms> TryParse(
            string input,
            IAudioService audioService,
            IDelayService delayService,
            ISpeechService speechService)
        {
            Ensure.ArgumentNotNull(input, nameof(input));
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return(ExerciseProgramsParser.GetParser(audioService, delayService, speechService).TryParse(input));
        }
Пример #26
0
        public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            delayService.AssertNotNull(nameof(delayService));
            speechService.AssertNotNull(nameof(speechService));
            promptSpeechText.AssertNotNull(nameof(promptSpeechText));

            if (duration < TimeSpan.Zero)
            {
                throw new ArgumentException("duration must be greater than or equal to zero.", "duration");
            }

            this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText));
        }
        public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            delayService.AssertNotNull(nameof(delayService));
            speechService.AssertNotNull(nameof(speechService));
            promptSpeechText.AssertNotNull(nameof(promptSpeechText));

            if (duration < TimeSpan.Zero)
            {
                throw new ArgumentException("duration must be greater than or equal to zero.", "duration");
            }

            this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText));
        }
Пример #28
0
 // parses a typed event matcher. e.g. "before set: ..." or "after rep: ..."
 // returns a matcher with action, where all specified actions are enclosed in a single sequence action
 private static Parser <MatcherWithAction> GetTypedEventMatcherWithActionParser <T>(
     Parser <Unit> nameParser,
     IAudioService audioService,
     IDelayService delayService,
     ISpeechService speechService)
     where T : IEvent =>
 from _ in Parse.String("*")
 from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
 from ___ in nameParser
 from ____ in Parse.Char(':').Token(HorizontalWhitespaceParser.Parser)
 from _____ in NewLineParser.Parser
 from actions in ActionListParser.GetParser(1, audioService, delayService, speechService)
 let action = new SequenceAction(actions)
              select new MatcherWithAction(new TypedEventMatcher <T>(), action);
Пример #29
0
        public ExerciseProgramsViewModelBuilder()
        {
            this.activation              = true;
            this.audioService            = new AudioServiceMock(MockBehavior.Loose);
            this.delayService            = new DelayServiceMock(MockBehavior.Loose);
            this.exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose);
            this.mainScheduler           = CurrentThreadScheduler.Instance;
            this.backgroundScheduler     = CurrentThreadScheduler.Instance;
            this.speechService           = new SpeechServiceMock(MockBehavior.Loose);
            this.stateService            = new StateServiceMock(MockBehavior.Loose);
            this.hostScreen              = new ScreenMock(MockBehavior.Loose);

            this.WithCachedDocument(null);
        }
        public static Parser <ExercisePrograms> GetParser(
            IAudioService audioService,
            IDelayService delayService,
            ISpeechService speechService)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                (from _ in VerticalSeparationParser.Parser
                 from exercisePrograms in ExerciseProgramParser.GetParser(audioService, delayService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional()
                 from __ in Parse.WhiteSpace.Many().End()
                 select new ExercisePrograms(exercisePrograms.GetOrElse(Enumerable.Empty <ExerciseProgram>())));
        }
        public static IResult<ExercisePrograms> TryParse(
            string input,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            input.AssertNotNull(nameof(input));
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return ExerciseProgramsParser.GetParser(audioService, delayService, loggerService, speechService).TryParse(input);
        }
Пример #32
0
        public static Parser <ExerciseProgram> GetParser(
            IAudioService audioService,
            IDelayService delayService,
            ISpeechService speechService)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                (from name in HeadingParser.GetParser(1)
                 from _ in Parse.WhiteSpace.Many()
                 from exercises in ExerciseParser.GetParser(audioService, delayService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional()
                 select new ExerciseProgram(name, exercises.GetOrElse(Enumerable.Empty <Exercise>())));
        }
Пример #33
0
        public static IResult<ExercisePrograms> TryParse(
            string input,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            Ensure.ArgumentNotNull(input, nameof(input));
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return ExerciseProgramsParser.GetParser(audioService, delayService, loggerService, speechService).TryParse(input);
        }
        private static IEnumerable<IAction> GetInnerActions(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            yield return new SayAction(speechService, promptSpeechText);

            if (duration < minimumBreakToIncludeReady)
            {
                yield return new WaitAction(delayService, duration);
            }
            else
            {
                yield return new WaitAction(delayService, duration - minimumBreakToIncludeReady);
                yield return new SayAction(speechService, "ready?");
                yield return new WaitAction(delayService, minimumBreakToIncludeReady);
            }
        }
        public static Parser<ExercisePrograms> GetParser(
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                from _ in VerticalSeparationParser.Parser
                from exercisePrograms in ExerciseProgramParser.GetParser(audioService, delayService, loggerService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional()
                from __ in Parse.WhiteSpace.Many().End()
                select new ExercisePrograms(exercisePrograms.GetOrElse(Enumerable.Empty<ExerciseProgram>()));
        }
Пример #36
0
 /// <summary>
 /// For testing purposes only.
 /// </summary>
 internal SymbolSearchUpdateEngine(
     ISymbolSearchLogService logService,
     IRemoteControlService remoteControlService,
     IDelayService delayService,
     IIOService ioService,
     IPatchService patchService,
     IDatabaseFactoryService databaseFactoryService,
     Func <Exception, bool> reportAndSwallowException)
 {
     _delayService              = delayService;
     _ioService                 = ioService;
     _logService                = logService;
     _remoteControlService      = remoteControlService;
     _patchService              = patchService;
     _databaseFactoryService    = databaseFactoryService;
     _reportAndSwallowException = reportAndSwallowException;
 }
        private static IEnumerable<IAction> GetInnerActions(IAudioService audioService, IDelayService delayService, ILoggerService loggerService, IEnumerable<MetronomeTick> ticks)
        {
            foreach (var tick in ticks)
            {
                yield return new WaitAction(delayService, tick.PeriodBefore);

                switch (tick.Type)
                {
                    case MetronomeTickType.Click:
                        yield return new DoNotAwaitAction(loggerService, new AudioAction(audioService, "MetronomeClick"));
                        break;
                    case MetronomeTickType.Bell:
                        yield return new DoNotAwaitAction(loggerService, new AudioAction(audioService, "MetronomeBell"));
                        break;
                }
            }
        }
Пример #38
0
        public static Parser <ParallelAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ISpeechService speechService)
        {
            Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel");
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                (from _ in Parse.IgnoreCase("parallel:")
                 from __ in VerticalSeparationParser.Parser.AtLeastOnce()
                 from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, speechService)
                 select new ParallelAction(actions));
        }
        public static Parser<ExerciseProgram> GetParser(
                IAudioService audioService,
                IDelayService delayService,
                ILoggerService loggerService,
                ISpeechService speechService)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return
                from name in HeadingParser.GetParser(1)
                from _ in Parse.WhiteSpace.Many()
                from exercises in ExerciseParser.GetParser(audioService, delayService, loggerService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional()
                select new ExerciseProgram(loggerService, name, exercises.GetOrElse(Enumerable.Empty<Exercise>()));
        }
Пример #40
0
        public static Parser <IEnumerable <IAction> > GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ISpeechService speechService)
        {
            Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel");
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                ((from _ in Parse.String("  ").Or(Parse.String("\t")).Repeat(indentLevel)
                  from __ in Parse.String("* ")
                  from action in ActionParser.GetParser(indentLevel, audioService, delayService, speechService).Token(HorizontalWhitespaceParser.Parser)
                  select action).DelimitedBy(NewLineParser.Parser));
        }
Пример #41
0
        private static IEnumerable <IAction> GetInnerActions(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText)
        {
            yield return(new SayAction(speechService, promptSpeechText));

            if (duration < minimumBreakToIncludeReady)
            {
                yield return(new WaitAction(delayService, duration));
            }
            else
            {
                yield return(new WaitAction(delayService, duration - minimumBreakToIncludeReady));

                yield return(new SayAction(speechService, "ready?"));

                yield return(new WaitAction(delayService, minimumBreakToIncludeReady));
            }
        }
        public ExerciseProgramsViewModelBuilder()
        {
            this.audioService = new AudioServiceMock(MockBehavior.Loose);
            this.delayService = new DelayServiceMock(MockBehavior.Loose);
            this.exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose);
            this.loggerService = new LoggerServiceMock(MockBehavior.Loose);
            this.schedulerService = new SchedulerServiceMock(MockBehavior.Loose);
            this.speechService = new SpeechServiceMock(MockBehavior.Loose);
            this.stateService = new StateServiceMock(MockBehavior.Loose);
            this.hostScreen = new ScreenMock(MockBehavior.Loose);
            this.exerciseProgramViewModelFactory =
                model =>
                    new ExerciseProgramViewModelBuilder()
                        .WithModel(model)
                        .Build();

            this.WithCachedDocument(null);
        }
        public CommandHandlerDelayDecorator(
            [NotNull] ICommandHandler <TCommand> decoratee,
            [NotNull] IReadOnlyConfigurationService configurationService,
            [NotNull] IDelayService delayService)
        {
            Guard.NotNull(decoratee, nameof(decoratee));
            Guard.NotNull(configurationService, nameof(configurationService));
            Guard.NotNull(delayService, nameof(delayService));

            this.delayService         = delayService;
            this.configurationService = configurationService;
            this.decoratee            = decoratee;

            disposables = new CompositeDisposable(1)
            {
                configurationService.ConfigurationChanged.Subscribe(data => configuration = null),
            };
        }
Пример #44
0
        public static Parser <MetronomeAction> GetParser(
            IAudioService audioService,
            IDelayService delayService)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));

            return
                (from _ in Parse.IgnoreCase("metronome")
                 from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from ___ in Parse.IgnoreCase("at")
                 from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from ticks in metronomeTickParser.DelimitedBy(Parse.Char(',').Token(HorizontalWhitespaceParser.Parser))
                 select new MetronomeAction(
                     audioService,
                     delayService,
                     ticks));
        }
        public ExerciseProgramsViewModelBuilder()
        {
            this.audioService            = new AudioServiceMock(MockBehavior.Loose);
            this.delayService            = new DelayServiceMock(MockBehavior.Loose);
            this.exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose);
            this.loggerService           = new LoggerServiceMock(MockBehavior.Loose);
            this.schedulerService        = new SchedulerServiceMock(MockBehavior.Loose);
            this.speechService           = new SpeechServiceMock(MockBehavior.Loose);
            this.stateService            = new StateServiceMock(MockBehavior.Loose);
            this.hostScreen = new ScreenMock(MockBehavior.Loose);
            this.exerciseProgramViewModelFactory =
                model =>
                new ExerciseProgramViewModelBuilder()
                .WithModel(model)
                .Build();

            this.WithCachedDocument(null);
        }
Пример #46
0
        public static Parser <PrepareAction> GetParser(
            IDelayService delayService,
            ISpeechService speechService)
        {
            delayService.AssertNotNull(nameof(delayService));
            speechService.AssertNotNull(nameof(speechService));

            return
                (from _ in Parse.IgnoreCase("prepare")
                 from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from ___ in Parse.IgnoreCase("for")
                 from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                 from duration in TimeSpanParser.Parser
                 select new PrepareAction(
                     delayService,
                     speechService,
                     duration));
        }
        public static Parser<PrepareAction> GetParser(
            IDelayService delayService,
            ISpeechService speechService)
        {
            delayService.AssertNotNull(nameof(delayService));
            speechService.AssertNotNull(nameof(speechService));

            return
                from _ in Parse.IgnoreCase("prepare")
                from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from ___ in Parse.IgnoreCase("for")
                from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from duration in TimeSpanParser.Parser
                select new PrepareAction(
                    delayService,
                    speechService,
                    duration);
        }
Пример #48
0
        public static Parser<IEnumerable<IAction>> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel");
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                (from _ in Parse.String("  ").Or(Parse.String("\t")).Repeat(indentLevel)
                 from __ in Parse.String("* ")
                 from action in ActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService).Token(HorizontalWhitespaceParser.Parser)
                 select action).DelimitedBy(NewLineParser.Parser);
        }
        public static Parser<SequenceAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel");
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return
                from _ in Parse.IgnoreCase("sequence:")
                from __ in VerticalSeparationParser.Parser.AtLeastOnce()
                from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService)
                select new SequenceAction(actions);
        }
Пример #50
0
        /// <summary>
        /// For testing purposes only.
        /// </summary>
        internal SymbolSearchUpdateEngine(
            ISymbolSearchLogService logService,
            IRemoteControlService remoteControlService,
            IDelayService delayService,
            IIOService ioService,
            IPatchService patchService,
            IDatabaseFactoryService databaseFactoryService,
            Func<Exception, bool> reportAndSwallowException,
            CancellationToken updateCancellationToken)
        {
            _delayService = delayService;
            _ioService = ioService;
            _logService = logService;
            _remoteControlService = remoteControlService;
            _patchService = patchService;
            _databaseFactoryService = databaseFactoryService;
            _reportAndSwallowException = reportAndSwallowException;

            _updateCancellationToken = updateCancellationToken;
        }
        public static Parser<MetronomeAction> GetParser(
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));

            return
                from _ in Parse.IgnoreCase("metronome")
                from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from ___ in Parse.IgnoreCase("at")
                from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce()
                from ticks in metronomeTickParser.DelimitedBy(Parse.Char(',').Token(HorizontalWhitespaceParser.Parser))
                select new MetronomeAction(
                    audioService,
                    delayService,
                    loggerService,
                    ticks);
        }
Пример #52
0
        public static Parser<IAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel");
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));

            return BreakActionParser.GetParser(delayService, speechService)
                .Or<IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService))
                .Or<IAction>(PrepareActionParser.GetParser(delayService, speechService))
                .Or<IAction>(SayActionParser.GetParser(speechService))
                .Or<IAction>(WaitActionParser.GetParser(delayService))
                .Or<IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                .Or<IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService))
                .Or<IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService));
        }
        public static Parser<ParallelAction> GetParser(
            int indentLevel,
            IAudioService audioService,
            IDelayService delayService,
            ILoggerService loggerService,
            ISpeechService speechService)
        {
            if (indentLevel < 0)
            {
                throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel");
            }

            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));

            return
                from _ in Parse.IgnoreCase("parallel:")
                from __ in VerticalSeparationParser.Parser.AtLeastOnce()
                from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService)
                select new ParallelAction(actions);
        }
Пример #54
0
 public PrepareAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration)
 {
     this.innerAction = new WaitWithPromptAction(delayService, speechService, duration, "prepare");
 }
 public WaitWithPromptActionBuilder()
 {
     this.delayService = new DelayServiceMock(MockBehavior.Loose);
     this.speechService = new SpeechServiceMock(MockBehavior.Loose);
     this.promptSpeechText = "prompt";
 }
 public WaitActionBuilder WithDelayService(IDelayService delayService)
 {
     this.delayService = delayService;
     return this;
 }
 public WaitActionBuilder()
 {
     this.delayService = new DelayServiceMock(MockBehavior.Loose);
 }
 public MetronomeActionBuilder WithDelayService(IDelayService delayService)
 {
     this.delayService = delayService;
     return this;
 }
Пример #59
0
 public BreakAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration)
 {
     this.innerAction = new WaitWithPromptAction(delayService, speechService, duration, "break");
 }