Skip to content

Commit

Permalink
Code review updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrimc62 committed Jun 1, 2016
1 parent 21fd347 commit 027ee0d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions CSharp/Library/FormFlow/FormDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async Task IDialog<T>.StartAsync(IDialogContext context)
builder.Append(entity.Entity);
builder.Append(' ');
}
inputs.Add(new Tuple<int, string>(_form.StepIndex(step), builder.ToString()));
inputs.Add(Tuple.Create(_form.StepIndex(step), builder.ToString()));
}
}
_formState.FieldInputs = (from input in inputs orderby input.Item1 descending select input).ToList();
Expand Down Expand Up @@ -307,7 +307,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
var next = (_formState.Next == null ? new NextStep() : ActiveSteps(_formState.Next, _state));
bool waitForMessage = false;
FormPrompt lastPrompt = _formState.LastPrompt;
Func<FormPrompt, Task<FormPrompt>> Post = async (prompt) =>
Func<FormPrompt, Task<FormPrompt>> PostAsync = async (prompt) =>
{
if (prompt != null)
{
Expand All @@ -318,18 +318,18 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
}
return prompt;
};
Func<IStep<T>, IEnumerable<TermMatch>, Task<bool>> DoStep = async (step, matches) =>
Func<IStep<T>, IEnumerable<TermMatch>, Task<bool>> DoStepAsync = async (step, matches) =>
{
var result = await step.ProcessAsync(context, _state, _formState, stepInput, matches);
next = result.Next;
if (result.Feedback?.Prompt != null)
{
await Post(result.Feedback);
await PostAsync(result.Feedback);
if (_formState.Phase() != StepPhase.Completed)
{
if (!_formState.ProcessInputs)
{
await Post(lastPrompt);
await PostAsync(lastPrompt);
waitForMessage = true;
}
else
Expand All @@ -341,7 +341,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
}
if (result.Prompt != null)
{
lastPrompt = await Post(result.Prompt);
lastPrompt = await PostAsync(result.Prompt);
waitForMessage = true;
}
return true;
Expand All @@ -358,7 +358,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
step = new NavigationStep<T>(_form.Steps[_formState.Step].Name, _form, _state, _formState);
if (start)
{
lastPrompt = await Post(step.Start(context, _state, _formState));
lastPrompt = await PostAsync(step.Start(context, _state, _formState));
waitForMessage = true;
}
else
Expand All @@ -377,7 +377,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
{
if (step.Type == StepType.Message)
{
await Post(step.Start(context, _state, _formState));
await PostAsync(step.Start(context, _state, _formState));
next = new NextStep();
}
else if (_formState.ProcessInputs)
Expand All @@ -387,7 +387,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
}
else
{
lastPrompt = await Post(step.Start(context, _state, _formState));
lastPrompt = await PostAsync(step.Start(context, _state, _formState));
waitForMessage = true;
}
}
Expand All @@ -408,7 +408,7 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
matches = MatchAnalyzer.Coalesce(matches, stepInput).ToArray();
if (MatchAnalyzer.IsFullMatch(stepInput, matches))
{
await DoStep(step, matches);
await DoStepAsync(step, matches);
}
else
{
Expand All @@ -426,16 +426,16 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
next = DoCommand(context, _state, _formState, step, commands, out feedback);
if (feedback != null)
{
await Post(feedback);
await Post(lastPrompt);
await PostAsync(feedback);
await PostAsync(lastPrompt);
waitForMessage = true;
}
}
else
{
if (matches.Count() == 0 && commands.Count() == 0)
{
await Post(step.NotUnderstood(context, _state, _formState, toBotText));
await PostAsync(step.NotUnderstood(context, _state, _formState, toBotText));
waitForMessage = true;
}
else
Expand All @@ -444,16 +444,16 @@ public async Task MessageReceived(IDialogContext context, IAwaitable<Connector.M
var bestMatch = MatchAnalyzer.BestMatches(matches, commands);
if (bestMatch == 0)
{
await DoStep(step, matches);
await DoStepAsync(step, matches);
}
else
{
FormPrompt feedback;
next = DoCommand(context, _state, _formState, step, commands, out feedback);
if (feedback != null)
{
await Post(feedback);
await Post(lastPrompt);
await PostAsync(feedback);
await PostAsync(lastPrompt);
waitForMessage = true;
}
}
Expand Down

0 comments on commit 027ee0d

Please sign in to comment.