IFormDialog.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 
36 using System;
37 using System.Collections.Generic;
38 using System.Threading.Tasks;
39 
40 namespace Microsoft.Bot.Builder.FormFlow
41 {
48  public delegate bool ActiveDelegate<T>(T state);
49 
53  [Serializable]
54  public class Choice
55  {
59  public object Value;
60 
65 
70  }
71 
79  public class ValidateResult
80  {
82  public string Feedback;
83 
88 
90  public bool IsValid;
91 
96  public object Value;
97 
101  public IEnumerable<Choice> Choices;
102  }
103 
111  public delegate Task<ValidateResult> ValidateAsyncDelegate<T>(T state, object value);
112 
124  public delegate Task OnCompletionAsyncDelegate<T>(IDialogContext context, T state);
125 
134  public interface IFormDialog<T> : IDialog<T>
135  where T : class
136  {
140  IForm<T> Form { get; }
141  }
142 
146  public enum FormCommand
147  {
151  Backup,
152 
156  Help,
157 
161  Quit,
162 
166  Reset,
167 
171  Status
172  };
173 
177  public class CommandDescription
178  {
182  public string Description;
183 
187  public string[] Terms;
188 
192  public string Help;
193 
200  public CommandDescription(string description, string[] terms, string help)
201  {
202  Description = description;
203  Terms = terms;
204  Help = help;
205  }
206  }
207 
208  #region Documentation
209  #endregion
213  [Serializable]
214  public class FormCanceledException : OperationCanceledException
215  {
216  #region Documentation
217  #endregion
222  public FormCanceledException(string message, Exception inner)
223  : base(message, inner)
224  {
225  }
226 
228  public IEnumerable<string> Completed { get; internal set; }
229 
231  public string Last { get; internal set; }
232  }
233 
234  #region Documentation
235  #endregion
238  [Serializable]
240  {
245  public FormCanceledException(string message, Exception inner = null)
246  : base(message, inner)
247  {
248  LastForm = default(T);
249  }
250 
252  public T LastForm { get; internal set; }
253  }
254 }
255 
Core namespace for FormFlow and associated infrastructure.
Definition: Attributes.cs:39
string Description
Description of the command.
Definition: IFormDialog.cs:182
IEnumerable< Choice > Choices
Choices for clarifying response.
Definition: IFormDialog.cs:101
The context for the execution of a dialog&#39;s conversational process.
bool IsValid
True if value is a valid response.
Definition: IFormDialog.cs:90
CommandDescription(string description, string[] terms, string help)
Construct the description of a built-in command.
Definition: IFormDialog.cs:200
DescribeAttribute Description
Description of value.
Definition: IFormDialog.cs:64
What to display when asked for help.
FormPrompt FeedbackCard
Fully specified feedback card.
Definition: IFormDialog.cs:87
string Feedback
Feedback to provide back to the user on the input.
Definition: IFormDialog.cs:82
string[] Terms
Regexs for matching the command.
Definition: IFormDialog.cs:187
Attribute to override the default terms used to match a field, property or enum value to user input...
Definition: Attributes.cs:119
A IDialog<TResult> is a suspendable conversational process that produces a result of type TResult ...
Definition: IDialog.cs:47
Namespace for FormFlow advanced building blocks.
Definition: Attributes.cs:672
Form definition interface.
Definition: IForm.cs:47
Interface for controlling a FormFlow dialog.
Definition: IFormDialog.cs:134
Encapsulates the result of a ValidateAsyncDelegate<T>
Definition: IFormDialog.cs:79
object Value
Value to put in the field if result is valid.
Definition: IFormDialog.cs:96
Provide feedback to the user on the current form state.
Quit the form and return failure to the parent dialog.
FormCanceledException(string message, Exception inner)
Constructor with message and inner exception.
Definition: IFormDialog.cs:222
Exception generated when form filling is canceled by user quit or exception.
Definition: IFormDialog.cs:214
FormCommand
Commands supported in form dialogs.
Definition: IFormDialog.cs:146
string Help
Help string for the command.
Definition: IFormDialog.cs:192
Description of all the information needed for a built-in command.
Definition: IFormDialog.cs:177
FormCanceledException(string message, Exception inner=null)
Constructor with message and inner exception.
Definition: IFormDialog.cs:245
Core namespace for Dialogs and associated infrastructure.
Choice for clarifying an ambiguous value in ValidateResult.
Definition: IFormDialog.cs:54
object Value
Value to return if choice is selected.
Definition: IFormDialog.cs:59
Root namespace for the Microsoft Bot Builder SDK.
TermsAttribute Terms
Terms to match value.
Definition: IFormDialog.cs:69
Attribute to override the default description of a field, property or enum value. ...
Definition: Attributes.cs:62
The prompt that is returned by form prompter.
Definition: IPrompt.cs:85