Ejemplo n.º 1
0
        private async Task _validator(ITurnContext turnContext, PromptValidatorContext <Activity> promptContext, CancellationToken cancellationToken)
        {
            var activity = (Activity)promptContext.Recognized.Value;

            if (activity.Type == ActivityTypes.Event)
            {
                if ((int)activity.Value == 2)
                {
                    promptContext.End(activity.Value);
                }
            }
            else
            {
                await turnContext.SendActivityAsync("Please send an 'event'-type Activity with a value of 2.");
            }
        }
 private Task CustomValidator(ITurnContext turnContext, PromptValidatorContext <IList <DateTimeResolution> > prompt, CancellationToken cancellationToken)
 {
     if (prompt.Recognized.Succeeded)
     {
         var resolution = prompt.Recognized.Value.First();
         // re-write the resolution to just include the date part.
         var rewrittenResolution = new DateTimeResolution
         {
             Timex = resolution.Timex.Split('T')[0],
             Value = resolution.Value.Split(' ')[0]
         };
         prompt.End(new List <DateTimeResolution> {
             rewrittenResolution
         });
     }
     return(Task.CompletedTask);
 }