protected async override Task PostAsync(Activity item, string state, CancellationToken token) { var message = item as IMessageActivity; if (message != null) { stack.Reset(); var root = new RootDialog(); await stack.Forward(root, null, message, CancellationToken.None); await task.PollAsync(CancellationToken.None); } }
/// <summary> /// Interrupt the waiting dialog with a new dialog /// </summary> /// <typeparam name="T">The type of result expected from the dialog.</typeparam> /// <typeparam name="R">The type of the item posted to dialog.</typeparam> /// <param name="stack">The dialog stack.</param> /// <param name="dialog">The new interrupting dialog.</param> /// <param name="item">The item to foward to the new interrupting dialog.</param> /// <param name="token">The cancellation token.</param> /// <returns>A task that represents the interruption operation.</returns> public static async Task InterruptAsync <T, R>(this IDialogStack stack, IDialog <T> dialog, R item, CancellationToken token) { await stack.Forward(dialog.Void <T, R>(), null, item, token); await stack.PollAsync(token); }
/// <summary> /// Call a child dialog, add it to the top of the stack and post the message to the child dialog. /// </summary> /// <typeparam name="R">The type of result expected from the child dialog.</typeparam> /// <param name="stack">The dialog stack.</param> /// <param name="child">The child dialog.</param> /// <param name="resume">The method to resume when the child dialog has completed.</param> /// <param name="message">The message that will be posted to child dialog.</param> /// <param name="token">A cancellation token.</param> /// <returns>A task representing the Forward operation.</returns> public static async Task Forward <R>(this IDialogStack stack, IDialog <R> child, ResumeAfter <R> resume, IMessageActivity message, CancellationToken token) { await stack.Forward <R, IMessageActivity>(child, resume, message, token); }