Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit fc90007

Browse files
author
Tom Laird-McConnell
committed
remove input and output bindings
remove bindingpath more unit tests
1 parent 7dd94a2 commit fc90007

58 files changed

Lines changed: 497 additions & 700 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BaseInvokeDialog.cs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class BaseInvokeDialog : DialogAction
1717
// Expression for dialogId to call (allowing dynamic expression)
1818
private string dialogIdToCall;
1919

20-
public BaseInvokeDialog(string dialogIdToCall = null, string property = null, IDictionary<string, string> bindingOptions = null)
20+
public BaseInvokeDialog(string dialogIdToCall = null, IDictionary<string, string> bindingOptions = null)
2121
: base()
2222
{
2323
this.dialogIdToCall = dialogIdToCall;
@@ -26,11 +26,6 @@ public BaseInvokeDialog(string dialogIdToCall = null, string property = null, ID
2626
{
2727
this.Options = bindingOptions;
2828
}
29-
30-
if (!string.IsNullOrEmpty(property))
31-
{
32-
Property = property;
33-
}
3429
}
3530

3631
/// <summary>
@@ -46,26 +41,6 @@ public BaseInvokeDialog(string dialogIdToCall = null, string property = null, ID
4641
/// </summary>
4742
public Dialog Dialog { get; set; }
4843

49-
/// <summary>
50-
/// Gets or sets the property from memory to pass to the calling dialog and to set the return value to.
51-
/// </summary>
52-
/// <value>
53-
/// The property from memory to pass to the calling dialog and to set the return value to.
54-
/// </value>
55-
public string Property
56-
{
57-
get
58-
{
59-
return InputBindings.TryGetValue(DialogPath.VALUE, out string value) ? value : null;
60-
}
61-
62-
set
63-
{
64-
InputBindings[DialogPath.VALUE] = value;
65-
OutputBinding = value;
66-
}
67-
}
68-
6944
public override IEnumerable<Dialog> GetDependencies()
7045
{
7146
if (Dialog != null)
@@ -78,7 +53,7 @@ public override IEnumerable<Dialog> GetDependencies()
7853

7954
protected override string OnComputeId()
8055
{
81-
return $"{this.GetType().Name}[{Dialog?.Id ?? this.dialogIdToCall}:{this.BindingPath()}]";
56+
return $"{this.GetType().Name}[{Dialog?.Id ?? this.dialogIdToCall}]";
8257
}
8358

8459
protected Dialog ResolveDialog(DialogContext dc)

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BeginDialog.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
1616
public class BeginDialog : BaseInvokeDialog
1717
{
1818
[JsonConstructor]
19-
public BeginDialog(string dialogIdToCall = null, string property = null, IDictionary<string, string> options = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
20-
: base(dialogIdToCall, property, options)
19+
public BeginDialog(string dialogIdToCall = null, IDictionary<string, string> options = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
20+
: base(dialogIdToCall, options)
2121
{
2222
this.RegisterSourceLocation(callerPath, callerLine);
2323
}
2424

25+
/// <summary>
26+
/// Gets or sets the property path to store the dialog result in
27+
/// </summary>
28+
public string ResultProperty { get; set; }
29+
2530
protected async override Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
2631
{
2732
if (options is CancellationToken)
@@ -37,5 +42,16 @@ public BeginDialog(string dialogIdToCall = null, string property = null, IDictio
3742
// start dialog with bound options passed in as the options
3843
return await dc.BeginDialogAsync(dialog.Id, options: boundOptions, cancellationToken: cancellationToken).ConfigureAwait(false);
3944
}
45+
46+
public async override Task<DialogTurnResult> ResumeDialogAsync(DialogContext dc, DialogReason reason, object result = null, CancellationToken cancellationToken = default(CancellationToken))
47+
{
48+
if (this.ResultProperty != null)
49+
{
50+
dc.State.SetValue(this.ResultProperty, result);
51+
}
52+
53+
// By default just end the current dialog and return result to parent.
54+
return await dc.EndDialogAsync(result, cancellationToken).ConfigureAwait(false);
55+
}
4056
}
4157
}

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CancelAllDialogs.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Runtime.CompilerServices;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using Microsoft.Bot.Builder.Expressions.Parser;
89
using Newtonsoft.Json;
910

1011
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
@@ -24,17 +25,11 @@ public CancelAllDialogs([CallerFilePath] string callerPath = "", [CallerLineNumb
2425
/// <summary>
2526
/// Gets or sets event name.
2627
/// </summary>
27-
/// <value>
28-
/// Event name.
29-
/// </value>
3028
public string EventName { get; set; }
3129

3230
/// <summary>
33-
/// Gets or sets event value.
31+
/// Gets or sets value expression for EventValue
3432
/// </summary>
35-
/// <value>
36-
/// Event value.
37-
/// </value>
3833
public string EventValue { get; set; }
3934

4035
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
@@ -44,12 +39,13 @@ public CancelAllDialogs([CallerFilePath] string callerPath = "", [CallerLineNumb
4439
throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
4540
}
4641

47-
return await CancelAllParentDialogsAsync(dc, eventName: EventName ?? "cancelDialog", eventValue: EventValue, cancellationToken: cancellationToken).ConfigureAwait(false);
48-
}
42+
object eventValue = null;
43+
if (this.EventValue != null)
44+
{
45+
eventValue = new ExpressionEngine().Parse(this.EventValue).TryEvaluate(dc.State);
46+
}
4947

50-
protected override string OnComputeId()
51-
{
52-
return "CancelDialog()";
48+
return await CancelAllParentDialogsAsync(dc, eventName: EventName ?? "cancelDialog", eventValue: eventValue, cancellationToken: cancellationToken).ConfigureAwait(false);
5349
}
5450
}
5551
}

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/Case.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ public Case(string value = null, IEnumerable<Dialog> actions = null)
2525
/// <summary>
2626
/// Gets or sets value expression to be compared against condition.
2727
/// </summary>
28-
/// <value>
29-
/// Value expression to be compared against condition.
30-
/// </value>
3128
[JsonProperty("value")]
3229
public string Value { get; set; }
3330

3431
/// <summary>
3532
/// Gets or sets set of actions to be executed given that the condition of the switch matches the value of this case.
3633
/// </summary>
37-
/// <value>
38-
/// Set of actions to be executed given that the condition of the switch matches the value of this case.
39-
/// </value>
4034
[JsonProperty("actions")]
4135
public List<Dialog> Actions { get; set; } = new List<Dialog>();
4236

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CodeAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public CodeAction(CodeActionHandler codeHandler, [CallerFilePath] string callerP
3333

3434
protected override string OnComputeId()
3535
{
36-
return $"CodeAction({codeHandler.ToString()})";
36+
return $"{this.GetType().Name}({codeHandler.ToString()})";
3737
}
3838
}
3939
}

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DeleteProperty.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public DeleteProperty(string property, [CallerFilePath] string callerPath = "",
3232
}
3333

3434
/// <summary>
35-
/// Gets or sets property to path to remove Example: user.age will remove "age" from "user".
35+
/// Gets or sets property path to remove.
3636
/// </summary>
37-
/// <value>
38-
/// Property to path to remove Example: user.age will remove "age" from "user".
39-
/// </value>
37+
/// <example>
38+
/// user.age will remove "age" from "user".
39+
/// </example>
4040
public string Property { get; set; }
4141

4242
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public override IEnumerable<Dialog> GetDependencies()
8484
protected override string OnComputeId()
8585
{
8686
var idList = Actions.Select(s => s.Id);
87-
return $"{nameof(EditActions)}({this.ChangeType}|{string.Join(",", idList)})";
87+
return $"{this.GetType().Name}[{this.ChangeType}|{string.Join(",", idList)}]";
8888
}
8989
}
9090
}

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditArray.cs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
2020
public class EditArray : DialogAction
2121
{
2222
private Expression value;
23-
private Expression arrayProperty;
23+
private Expression itemsProperty;
2424
private Expression resultProperty;
2525

2626
/// <summary>
@@ -37,7 +37,7 @@ public EditArray(ArrayChangeType changeType, string arrayProperty = null, string
3737

3838
if (!string.IsNullOrEmpty(arrayProperty))
3939
{
40-
this.ArrayProperty = arrayProperty;
40+
this.ItemsProperty = arrayProperty;
4141
}
4242

4343
switch (changeType)
@@ -100,24 +100,18 @@ public enum ArrayChangeType
100100
public ArrayChangeType ChangeType { get; set; }
101101

102102
/// <summary>
103-
/// Gets or sets memory expression of the array to manipulate.
103+
/// Gets or sets property path expression to the collection of items.
104104
/// </summary>
105-
/// <value>
106-
/// Memory expression of the array to manipulate.
107-
/// </value>Edit
108-
[JsonProperty("arrayProperty")]
109-
public string ArrayProperty
105+
[JsonProperty("itemsProperty")]
106+
public string ItemsProperty
110107
{
111-
get { return arrayProperty?.ToString(); }
112-
set { this.arrayProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; }
108+
get { return itemsProperty?.ToString(); }
109+
set { this.itemsProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; }
113110
}
114111

115112
/// <summary>
116-
/// Gets or sets the result of the action.
113+
/// Gets or sets the path expression to store the result of the action.
117114
/// </summary>
118-
/// <value>
119-
/// The result of the action.
120-
/// </value>
121115
[JsonProperty("resultProperty")]
122116
public string ResultProperty
123117
{
@@ -126,11 +120,8 @@ public string ResultProperty
126120
}
127121

128122
/// <summary>
129-
/// Gets or sets the expression of the item to put onto the array.
123+
/// Gets or sets the expression of the value to put onto the array.
130124
/// </summary>
131-
/// <value>
132-
/// The expression of the item to put onto the array.
133-
/// </value>
134125
[JsonProperty("value")]
135126
public string Value
136127
{
@@ -140,7 +131,7 @@ public string Value
140131

141132
protected override string OnComputeId()
142133
{
143-
return $"array[{ChangeType + ": " + ArrayProperty}]";
134+
return $"{this.GetType().Name}[{ChangeType + ": " + ItemsProperty}]";
144135
}
145136

146137
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
@@ -150,12 +141,12 @@ protected override string OnComputeId()
150141
throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
151142
}
152143

153-
if (string.IsNullOrEmpty(ArrayProperty))
144+
if (string.IsNullOrEmpty(ItemsProperty))
154145
{
155146
throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed because the arrayProperty wasn't specified.");
156147
}
157148

158-
var array = dc.State.GetValue<JArray>(this.ArrayProperty, () => new JArray());
149+
var array = dc.State.GetValue<JArray>(this.ItemsProperty, () => new JArray());
159150

160151
object item = null;
161152
object result = null;
@@ -210,7 +201,7 @@ protected override string OnComputeId()
210201
break;
211202
}
212203

213-
dc.State.SetValue(this.ArrayProperty, array);
204+
dc.State.SetValue(this.ItemsProperty, array);
214205

215206
if (ResultProperty != null)
216207
{
@@ -224,7 +215,7 @@ private void EnsureValue()
224215
{
225216
if (Value == null)
226217
{
227-
throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed for array \"{ArrayProperty}\" because a value wasn't specified.");
218+
throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed for array \"{ItemsProperty}\" because a value wasn't specified.");
228219
}
229220
}
230221
}

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EmitEvent.cs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
1010
{
11+
/// <summary>
12+
/// Action which emits an event declaratively
13+
/// </summary>
1114
public class EmitEvent : DialogAction
1215
{
1316
private const string EventValuePropertyValue = "eventValue";
@@ -22,44 +25,36 @@ public EmitEvent(string eventName = null, object eventValue = null, bool bubble
2225
this.BubbleEvent = bubble;
2326
}
2427

28+
/// <summary>
29+
/// Gets or sets the name of the event to emit
30+
/// </summary>
2531
public string EventName { get; set; }
2632

27-
public object EventValue { get; set; }
33+
/// <summary>
34+
/// Gets or sets the object to send with the event
35+
/// </summary>
36+
public string EventValue { get; set; }
2837

38+
/// <summary>
39+
/// Gets or sets whether the event should bubble or not
40+
/// </summary>
2941
public bool BubbleEvent { get; set; }
3042

31-
public string EventValueProperty
32-
{
33-
get
34-
{
35-
if (InputBindings.ContainsKey(EventValuePropertyValue))
36-
{
37-
return InputBindings[EventValuePropertyValue];
38-
}
39-
40-
return string.Empty;
41-
}
42-
43-
set
44-
{
45-
InputBindings[EventValuePropertyValue] = value;
46-
}
47-
}
48-
4943
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
5044
{
5145
if (options is CancellationToken)
5246
{
5347
throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
5448
}
5549

56-
var handled = await dc.EmitEventAsync(EventName, EventValue, BubbleEvent, false, cancellationToken).ConfigureAwait(false);
50+
var eventValue = (this.EventValue != null) ? dc.State.GetValue<object>(this.EventValue) : null;
51+
var handled = await dc.EmitEventAsync(EventName, eventValue, BubbleEvent, false, cancellationToken).ConfigureAwait(false);
5752
return await dc.EndDialogAsync(handled, cancellationToken).ConfigureAwait(false);
5853
}
5954

6055
protected override string OnComputeId()
6156
{
62-
return $"EmitEvent[{EventName ?? string.Empty}]";
57+
return $"{this.GetType().Name}[{EventName ?? string.Empty}]";
6358
}
6459
}
6560
}

0 commit comments

Comments
 (0)