IStep.cs
1 //
2 // Copyright (c) Microsoft. All rights reserved.
3 // Licensed under the MIT license.
4 //
5 // Microsoft Bot Framework: http://botframework.com
6 //
7 // Bot Builder SDK GitHub:
8 // https://github.com/Microsoft/BotBuilder
9 //
10 // Copyright (c) Microsoft Corporation
11 // All rights reserved.
12 //
13 // MIT License:
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33 
34 using System.Collections.Generic;
35 using System.Threading.Tasks;
36 
38 
39 namespace Microsoft.Bot.Builder.FormFlow.Advanced
40 {
41  internal enum StepPhase { Ready, Responding, Completed };
42  internal enum StepType { Field, Confirm, Navigation, Message };
43 
44  internal struct StepResult
45  {
46  internal StepResult(bool success, NextStep next, FormPrompt feedback, FormPrompt prompt)
47  {
48  this.Success = success;
49  this.Next = next;
50  this.Feedback = feedback;
51  this.Prompt = prompt;
52  }
53 
54  internal NextStep Next { get; set; }
55  internal FormPrompt Feedback { get; set; }
56  internal FormPrompt Prompt { get; set; }
57  internal bool Success { get; set; }
58  }
59 
60  internal interface IStep<T>
61  where T : class
62  {
63  string Name { get; }
64 
65  StepType Type { get; }
66 
67  TemplateBaseAttribute Annotation { get; }
68 
69  IField<T> Field { get; }
70 
71  void SaveResources();
72 
73  void Localize();
74 
75  bool Active(T state);
76 
77  Task<bool> DefineAsync(T state);
78 
79  FormPrompt Start(IDialogContext context, T state, FormState form);
80 
81  bool InClarify(FormState form);
82 
83  IEnumerable<TermMatch> Match(IDialogContext context, T state, FormState form, string input);
84 
85  Task<StepResult> ProcessAsync(IDialogContext context, T state, FormState form, string input, IEnumerable<TermMatch> matches);
86 
87  FormPrompt NotUnderstood(IDialogContext context, T state, FormState form, string input);
88 
89  FormPrompt Help(T state, FormState form, string commandHelp);
90 
91  bool Back(IDialogContext context, T state, FormState form);
92 
93  IEnumerable<string> Dependencies { get; }
94  }
95 
96 }
The context for the execution of a dialog&#39;s conversational process.
How to show feedback after user input.
Match corresponds to a field, not a specific value in the field.
What to display when asked for help.
Response when an input is not understood.
Move to the next step that is IFieldPrompt<T>.Active(T) and uncompleted.
Field is used to confirm some settings during the dialog.
Core namespace for Dialogs and associated infrastructure.
Root namespace for the Microsoft Bot Builder SDK.