Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DialogContext"/> class.
        /// </summary>
        /// <param name="dialogs">Parent dialog set.</param>
        /// <param name="turnContext">Context for the current turn of conversation with the user.</param>
        /// <param name="state">Current dialog state.</param>
        internal DialogContext(DialogSet dialogs, TurnContext turnContext, DialogState state)
        {
            Dialogs = dialogs ?? throw new ArgumentNullException(nameof(dialogs));
            Context = turnContext ?? throw new ArgumentNullException(nameof(turnContext));

            Stack = state.DialogStack;
        }
Esempio n. 2
0
        public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext outerDc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (outerDc == null)
            {
                throw new ArgumentNullException(nameof(outerDc));
            }

            // Start the inner dialog.
            var dialogState = new DialogState();

            outerDc.ActiveDialog.State[PersistedDialogState] = dialogState;
            var innerDc = new DialogContext(_dialogs, outerDc.Context, dialogState);

            innerDc.Parent = outerDc;
            var turnResult = await OnBeginDialogAsync(innerDc, options, cancellationToken).ConfigureAwait(false);

            // Check for end of inner dialog
            if (turnResult.Status != DialogTurnStatus.Waiting)
            {
                // Return result to calling dialog
                return(await EndComponentAsync(outerDc, turnResult.Result, cancellationToken).ConfigureAwait(false));
            }
            else
            {
                // Just signal waiting
                return(Dialog.EndOfTurn);
            }
        }