Skip to content

Commit

Permalink
Merge pull request #3894 from microsoft/ccastro/adaptive-style
Browse files Browse the repository at this point in the history
merge CheckForVersionChangeAsync()
  • Loading branch information
Tom Laird-McConnell authored May 8, 2020
2 parents d935d31 + cb9d873 commit 478ca4a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public LogAction(string text = null, [CallerFilePath] string callerPath = "", [C
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}

var text = await Text.BindAsync(dc, dc.State).ConfigureAwait(false);
var text = await Text.BindAsync(dc, dc.State, cancellationToken: cancellationToken).ConfigureAwait(false);

var properties = new Dictionary<string, string>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public UpdateActivity(string text = null, [CallerFilePath] string callerPath = "
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}

var activity = await Activity.BindAsync(dc, dc.State).ConfigureAwait(false);
var activity = await Activity.BindAsync(dc, dc.State, cancellationToken: cancellationToken).ConfigureAwait(false);

var properties = new Dictionary<string, string>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public class OAuthInput : InputDialog
// increase the turnCount as last step
dc.State.SetValue(TURN_COUNT_PROPERTY, turnCount + 1);
var prompt = await this.OnRenderPromptAsync(dc, inputState, cancellationToken).ConfigureAwait(false);
await dc.Context.SendActivityAsync(prompt).ConfigureAwait(false);
await dc.Context.SendActivityAsync(prompt, cancellationToken).ConfigureAwait(false);
await SendOAuthCardAsync(dc, promptOptions?.Prompt, cancellationToken).ConfigureAwait(false);
return Dialog.EndOfTurn;
}
Expand Down
22 changes: 3 additions & 19 deletions libraries/Microsoft.Bot.Builder.Dialogs/DialogContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,15 @@ protected virtual string GetInternalVersion()
/// CheckForVersionChangeAsync.
/// </summary>
/// <param name="dc">dialog context.</param>
/// <param name="cancellationToken">cancellationToken.</param>
/// <returns>task.</returns>
/// <remarks>
/// Checks to see if a containers child dialogs have changed since the current dialog instance
/// was started.
///
/// This should be called at the start of `beginDialog()`, `continueDialog()`, and `resumeDialog()`.
/// </remarks>
protected virtual Task CheckForVersionChangeAsync(DialogContext dc)
{
return CheckForVersionChangeAsync(dc, default(CancellationToken));
}

/// <summary>
/// CheckForVersionChangeAsync.
/// </summary>
/// <param name="dc">dialog context.</param>
/// <param name="cancellationToken">cancellationToken.</param>
/// <returns>task.</returns>
/// <remarks>
/// Checks to see if a containers child dialogs have changed since the current dialog instance
/// was started.
///
/// This should be called at the start of `beginDialog()`, `continueDialog()`, and `resumeDialog()`.
/// </remarks>
protected virtual async Task CheckForVersionChangeAsync(DialogContext dc, CancellationToken cancellationToken)
protected virtual async Task CheckForVersionChangeAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
{
var current = dc.ActiveDialog.Version;
dc.ActiveDialog.Version = this.GetInternalVersion();
Expand All @@ -82,7 +66,7 @@ protected virtual async Task CheckForVersionChangeAsync(DialogContext dc, Cancel
// Give bot an opportunity to handle the change.
// - If bot handles it the changeHash will have been updated as to avoid triggering the
// change again.
var handled = await dc.EmitEventAsync(DialogEvents.VersionChanged, this.Id, true, false).ConfigureAwait(false);
var handled = await dc.EmitEventAsync(DialogEvents.VersionChanged, this.Id, true, false, cancellationToken).ConfigureAwait(false);
if (!handled)
{
// Throw an error for bot to catch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"$schema": "../../testbot.schema",
"$kind": "Microsoft.AdaptiveDialog",
"triggers": [
{
"$kind": "Microsoft.OnBeginDialog",
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "World"
},
{
"$kind": "Microsoft.EndTurn"
},
{
"$kind": "Microsoft.BeginDialog",
"dialog": "Root.dialog"
}
]
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "World"
},
{
"$kind": "Microsoft.EndTurn"
},
{
"$kind": "Microsoft.BeginDialog",
"dialog": "Root.dialog"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../testbot.schema",
"$kind": "Microsoft.AdaptiveDialog",
"triggers": [
{
Expand Down

0 comments on commit 478ca4a

Please sign in to comment.