示例#1
0
        public async Task DialogContinue(DialogContext dc)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            // Continue controls dialog stack.
            IDictionary <string, object> result = null;
            var cdc = new DialogContext(this.Dialogs, dc.Context, dc.ActiveDialog.State, (r) => { result = r; });
            await cdc.Continue();

            // End if the controls dialog ends.
            if (cdc.ActiveDialog == null)
            {
                await dc.End(result);
            }
        }
示例#2
0
        /// <summary>
        /// Passes a users reply to the dialog for further processing.The bot should keep calling
        /// 'continue()' for future turns until the dialog returns a completion object with
        /// 'isCompleted == true'. To cancel or interrupt the prompt simply delete the `state` object
        /// being persisted.
        /// </summary>
        /// <param name="context">Context for the current turn of the conversation with the user.</param>
        /// <param name="state">A state object that was previously initialized by a call to [begin()](#begin).</param>
        /// <returns>DialogCompletion result</returns>
        public async Task <DialogCompletion> Continue(ITurnContext context, IDictionary <string, object> state)
        {
            BotAssert.ContextNotNull(context);
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            // Create empty dialog set and ourselves to it
            var dialogs = new DialogSet();

            dialogs.Add("dialog", (IDialog)this);

            // Continue the dialog
            IDictionary <string, object> result = null;
            var dc = new DialogContext(dialogs, context, state, (r) => { result = r; });

            if (dc.ActiveDialog != null)
            {
                await dc.Continue();

                return(dc.ActiveDialog != null
                        ?
                       new DialogCompletion {
                    IsActive = true, IsCompleted = false
                }
                        :
                       new DialogCompletion {
                    IsActive = false, IsCompleted = true, Result = result
                });
            }
            else
            {
                return(new DialogCompletion {
                    IsActive = false, IsCompleted = false
                });
            }
        }