in SDKV4-Samples/dotnet_core/DialogInterruptionsBot/DialogInterruptionsBot.cs [440:485]
private static async Task<DialogTurnResult> LoopStepAsync(
WaterfallStepContext stepContext,
CancellationToken cancellationToken)
{
// Retrieve their selection list and the choice they juat made.
List<string> list = stepContext.Values[CompaniesSelected] as List<string>;
FoundChoice choice = (FoundChoice)stepContext.Result;
// Handle any local, expected interruptions appropriately.
switch (choice.Value)
{
case Interruptions.Finish:
// Exit and return their current selection list.
return await stepContext.EndDialogAsync(list, cancellationToken);
case Interruptions.Cancel:
// Exit and return null.
return await stepContext.EndDialogAsync(null, cancellationToken);
case Interruptions.Help:
// Dispaly the help options.
await stepContext.Context.SendActivityAsync(
Interruptions.HelpText,
cancellationToken: cancellationToken);
break;
case Interruptions.MoreInfo:
// Display more information about the companies.
await stepContext.Context.SendActivityAsync(
Companies.MoreInfo,
cancellationToken: cancellationToken);
break;
default:
// If they chose a company, add it to the list.
list.Add(choice.Value);
break;
}
if (list.Count is 2)
{
// If they've selected 2 companies to review, exit and return their list.
return await stepContext.EndDialogAsync(list, cancellationToken);
}
else
{
// Otherwise, repeat this dialog, passing in the list from this iteration.
return await stepContext.ReplaceDialogAsync(ReviewSelectionDialog, list, cancellationToken);
}
}