/// <summary> /// Post an item to the dialog task and poll the dialog task for any work to be done. /// </summary> /// <typeparam name="R">The type of the root dialog.</typeparam> /// <typeparam name="T">The type of the item.</typeparam> /// <param name="task">The dialog task.</param> /// <param name="toBot">The item to be sent to the bot.</param> /// <param name="MakeRoot">The factory method for the root dialog.</param> /// <param name="token">An optional cancellation token.</param> /// <returns>A task representing the post operation.</returns> public static async Task PostAsync <T, R>(this IDialogTask task, T toBot, Func <IDialog <R> > MakeRoot, CancellationToken token = default(CancellationToken)) { await LoadAsync(task, MakeRoot, token); IPostToBot postToBot = task; try { await postToBot.PostAsync(toBot, token); } catch { task.Reset(); throw; } task.Save(); }
/// <summary> /// Poll the dialog task for any work to be done. /// </summary> /// <typeparam name="R">The type of the root dialog.</typeparam> /// <param name="task">The dialog task.</param> /// <param name="MakeRoot">The factory method for the root dialog.</param> /// <param name="token">An optional cancellation token.</param> /// <returns>A task representing the poll operation.</returns> public static async Task PollAsync <R>(this IDialogTask task, Func <IDialog <R> > MakeRoot, CancellationToken token = default(CancellationToken)) { await LoadAsync(task, MakeRoot); task.Save(); }