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>())));
        }
Ejemplo n.º 2
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>())));
        }