Exemple #1
0
        // The notion of a Validator is a standard pattern across all the Prompts
        private static Task TimexValidator(ITurnContext context, TimexResult value)
        {
            var cadidates = value.Resolutions;

            var constraints = new[] {
                TimexCreator.ThisWeek(),                /* Take any entries for this week, no entries from past please */
                TimexCreator.NextWeek(),                /* Take any entries for next week, no dates from the past please */
                TimexCreator.Evening,                   /* Evenings only */
            };

            var resolutions = TimexRangeResolver.Evaluate(cadidates, constraints);

            if (resolutions.Count == 0)
            {
                value.Resolutions = new string[] { };
                value.Status      = Microsoft.Bot.Builder.Prompts.PromptStatus.OutOfRange;
            }
            else
            {
                value.Resolutions = new[] { resolutions.First().TimexValue };
                value.Status      = Microsoft.Bot.Builder.Prompts.PromptStatus.Recognized;
            }

            return(Task.CompletedTask);
        }
        private List <TimexProperty> evaluateTimeX(string[] candidates)
        {
            var constraints = new[] {
                TimexCreator.ThisWeek(),                /* Take any entries for this week, no entries from past please */
                TimexCreator.NextWeek(),                /* Take any entries for next week, no dates from the past please */
                TimexCreator.Evening,                   /* Evenings only */
            };

            return(TimexRangeResolver.Evaluate(candidates, constraints));
        }
        // The notion of a Validator is a standard pattern across all the Prompts
        private static Task TimexValidator(ITurnContext context, TimexResult value)
        {
            var cadidates = value.Resolutions;

            var constraints = new[] { TimexCreator.ThisWeek(), TimexCreator.NextWeek(), TimexCreator.Evening };

            var resolutions = TimexRangeResolver.Evaluate(cadidates, constraints);

            if (resolutions.Count == 0)
            {
                value.Resolutions = new string[] {};
                value.Status      = PromptStatus.OutOfRange;
            }
            else
            {
                value.Resolutions = new[] { resolutions.First().TimexValue };
                value.Status      = PromptStatus.Recognized;
            }

            return(Task.CompletedTask);
        }