Ejemplo n.º 1
0
        protected override async Task <DialogTurnResult> EndComponentAsync(DialogContext outerDc, object result, CancellationToken cancellationToken)
        {
            var doCancel = (bool)result;

            if (doCancel)
            {
                // If user chose to cancel
                await _responder.ReplyWith(outerDc.Context, CancelResponses._cancelConfirmed);

                // Cancel all in outer stack of component i.e. the stack the component belongs to
                return(await outerDc.CancelAllDialogsAsync());
            }
            else
            {
                // else if user chose not to cancel
                await _responder.ReplyWith(outerDc.Context, CancelResponses._cancelDenied);

                // End this component. Will trigger reprompt/resume on outer stack
                return(await outerDc.EndDialogAsync());
            }
        }
Ejemplo n.º 2
0
        private async Task <InterruptionAction> OnCancel(DialogContext dc)
        {
            if (dc.ActiveDialog != null && dc.ActiveDialog.Id != nameof(CancelDialog))
            {
                // Don't start restart cancel dialog
                await dc.BeginDialogAsync(nameof(CancelDialog));

                // Signal that the dialog is waiting on user response
                return(InterruptionAction.StartedDialog);
            }

            var view = new CancelResponses();
            await view.ReplyWith(dc.Context, CancelResponses.ResponseIds.NothingToCancelMessage);

            return(InterruptionAction.StartedDialog);
        }
Ejemplo n.º 3
0
        private async Task <InterruptionAction> OnReset(DialogContext dc)
        {
            await _userState.ClearStateAsync(dc.Context);

            var onboardingState = await _onboardingState.GetAsync(dc.Context);

            await dc.Context.SendActivityAsync($"The state has been reset.").ConfigureAwait(false);

            if (dc.ActiveDialog != null && dc.ActiveDialog.Id != nameof(CancelDialog))
            {
                // Don't start restart cancel dialog
                await dc.CancelAllDialogsAsync();

                // Signal that the dialog is waiting on user response
                return(InterruptionAction.StartedDialog);
            }

            var view = new CancelResponses();
            await view.ReplyWith(dc.Context, CancelResponses.ResponseIds.NothingToCancelMessage);

            return(InterruptionAction.StartedDialog);
        }