Beispiel #1
0
    private Task <DialogTurnResult> ResultRecievedAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        if (stepContext.Result is IList <DateTimeResolution> datetimes)
        {
            DateTime time = TimexHelper.GetDateTime(datetimes.First().Timex);

            return(stepContext.EndDialogAsync(time, cancellationToken));
        }
        else
        {
            throw new InvalidOperationException("Result is not datetimes");
        }
    }
Beispiel #2
0
    private Task <bool> ValidateDateTime(PromptValidatorContext <IList <DateTimeResolution> > promptContext, CancellationToken cancellationToken)
    {
        IList <DateTimeResolution> results = promptContext.Recognized.Value;

        if (results != null)
        {
            results = results.Where(r => !string.IsNullOrEmpty(r.Timex) && TimexHelper.IsDateTime(r.Timex)).ToList();

            return(Task.FromResult(results.Count > 0));
        }
        else
        {
            return(Task.FromResult(false));
        }
    }