Microsoft.Bot.Builder.Dialogs.Chain Class Reference

A fluent, chainable interface for IDialogs. More...

Classes

class  WhereCanceledException
 The exception that is thrown when the where is canceled. More...
 

Public Member Functions

delegate Task< IDialog< R > > Continuation< in T, R > (IBotContext context, IAwaitable< T > item)
 When the antecedent IDialog<T> has completed, execute this continuation method to construct the next IDialog<R>. More...
 

Static Public Member Functions

static ICase< string, R > Case< R > (Regex regex, ContextualSelector< string, R > selector)
 Constructs a case based on a regular expression. More...
 
static ICase< T, R > Case< T, R > (Func< T, bool > condition, ContextualSelector< T, R > selector)
 Constructs a case. More...
 
static IDialog< T > Catch< T > (this IDialog< T > antecedent, Func< IDialog< T >, Exception, IDialog< T >> block)
 When the antecedent IDialog<T> has completed, catch and handle any exceptions. More...
 
static IDialog< T > Catch< T, E > (this IDialog< T > antecedent, Func< IDialog< T >, E, IDialog< T >> block)
 When the antecedent IDialog<T> has completed, catch and handle any exceptions of type E . More...
 
static IDialog< R > ContinueWith< T, R > (this IDialog< T > antecedent, Continuation< T, R > continuation)
 When the antecedent IDialog<T> has completed, execute the continuation to produce the next IDialog<R>. More...
 
static ICase< T, R > Default< T, R > (ContextualSelector< T, R > selector)
 Constructs a case to use as the default. More...
 
static IDialog< T > DefaultIfException< T > (this IDialog< T > antecedent)
 When the antecedent IDialog<T> has completed, stop the propagation of Exception. More...
 
static IDialog< T > DefaultIfException< T, E > (this IDialog< T > antecedent)
 When the antecedent IDialog<T> has completed, stop the propagation of an exception of E . More...
 
static IDialog< T > Do< T > (this IDialog< T > antecedent, Func< IBotContext, IAwaitable< T >, Task > callback)
 Execute a side-effect after a IDialog<T> completes. More...
 
static IDialog< T > Fold< T > (this IDialog< IEnumerable< IDialog< T >>> antecedent, Func< T, T, T > folder)
 Fold items from an enumeration of dialogs. More...
 
static IDialog< T > From< T > (Func< IDialog< T >> MakeDialog)
 Construct a IDialog<T> that will make a new copy of another IDialog<T> when started. More...
 
static IDialog< T > Loop< T > (this IDialog< T > antecedent)
 Loop the IDialog<T> forever. More...
 
static IDialog< T > PostEvent< T, E > (this IDialog< T > antecedent, E @event)
 When the antecedent IDialog<T> has completed, post the item to the event queue. More...
 
static IDialog< IMessageActivityPostToChain ()
 Post the message from the user to Chain. More...
 
static IDialog< T > PostToUser< T > (this IDialog< T > antecedent)
 Post to the user the result of a IDialog<T>. More...
 
static IDialog< T > Return< T > (T item)
 Creates a IDialog<T> that returns a value. More...
 
static IDialog< R > Select< T, R > (this IDialog< T > antecedent, Func< T, R > selector)
 When the antecedent IDialog<T> has completed, project the result into a new IDialog<R>. More...
 
static IDialog< R > SelectMany< T, C, R > (this IDialog< T > antecedent, Func< T, IDialog< C >> function, Func< T, C, R > projection)
 When the antecedent IDialog<T> has completed, execute the next IDialog<C>, and use the projection to combine the results. More...
 
static IDialog< R > Switch< T, R > (this IDialog< T > antecedent, params ICase< T, R >[] cases)
 When the antecedent IDialog<T> has completed, go through each ICase<T, R> and run the ContextualSelector<T, R>" of the first <see cref="ICase{T, R}"/> that the returned value by the antecedent dialog satisfies. More...
 
static IDialog< R > Then< T, R > (this IDialog< T > Antecedent, Func< IBotContext, IAwaitable< T >, Task< R >> Action)
 Execute an action after the IDialog<T> completes. More...
 
static IDialog< T > Unwrap< T > (this IDialog< IDialog< T >> antecedent)
 When the antecedent IDialog<T> where T is IDialog<T> completes, unwrap the result into a new IDialog<T>. More...
 
static IDialog< object > Void< T > (this IDialog< T > antecedent, IDialogStack stack)
 Call the voided IDialog<T>, ignore the result, then restart the original dialog wait. More...
 
static IDialog< R > Void< T, R > (this IDialog< T > antecedent)
 Call the voided IDialog<T>, ignore the result, then restart the original dialog wait. More...
 
static IDialog< IMessageActivityWaitToBot< T > (this IDialog< T > antecedent)
 Post to the chain the message to the bot after the antecedent completes. More...
 
static IDialog< T > Where< T > (this IDialog< T > antecedent, Func< T, bool > predicate)
 When the antecedent IDialog<T> has completed, evaluate the predicate and decide whether to continue. More...
 
static IDialog< T > While< T > (this IDialog< T > initial, Func< T, IDialog< bool >> test, Func< T, IDialog< T >> body)
 Create a IDialog<T> that represents a while loop. More...
 
static IDialog< T > WithScorable< T, Item, Score > (this IDialog< T > antecedent, IScorable< Item, Score > scorable)
 Decorate a dialog with a scorable, so that a scorable can participate on the dialog stack. More...
 

Detailed Description

A fluent, chainable interface for IDialogs.

Definition at line 52 of file Chain.cs.

Member Function Documentation

static ICase<string, R> Microsoft.Bot.Builder.Dialogs.Chain.Case< R > ( Regex  regex,
ContextualSelector< string, R >  selector 
)
inlinestatic

Constructs a case based on a regular expression.

Template Parameters
RThe type of the object returned by selector.
Parameters
regexThe regex for condition.
selectorThe contextual selector for the case.
Returns
The case.

Definition at line 416 of file Chain.cs.

static ICase<T, R> Microsoft.Bot.Builder.Dialogs.Chain.Case< T, R > ( Func< T, bool >  condition,
ContextualSelector< T, R >  selector 
)
inlinestatic

Constructs a case.

Template Parameters
TThe type of incoming value to case.
RThe type of the object returned by selector.
Parameters
conditionThe condition of the case.
selectorThe contextual selector of the case.
Returns

Definition at line 404 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Catch< T > ( this IDialog< T >  antecedent,
Func< IDialog< T >, Exception, IDialog< T >>  block 
)
inlinestatic

When the antecedent IDialog<T> has completed, catch and handle any exceptions.

Template Parameters
TThe type returned by the antecedent dialog.
Parameters
antecedentThe antecedent dialog IDialog<T>.
blockThe lambda expression representing the catch block handler.
Returns
The result of the catch block handler if there is an exception.

Definition at line 300 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Catch< T, E > ( this IDialog< T >  antecedent,
Func< IDialog< T >, E, IDialog< T >>  block 
)
inlinestatic

When the antecedent IDialog<T> has completed, catch and handle any exceptions of type E .

Template Parameters
TThe type returned by the antecedent dialog.
EThe type of exception to catch and handle.
Parameters
antecedentThe antecedent dialog IDialog<T>.
blockThe lambda expression representing the catch block handler.
Returns
The result of the catch block handler if there is an exception of type E .
Type Constraints
E :Exception 

Definition at line 288 of file Chain.cs.

delegate Task<IDialog<R> > Microsoft.Bot.Builder.Dialogs.Chain.Continuation< in T, R > ( IBotContext  context,
IAwaitable< T >  item 
)

When the antecedent IDialog<T> has completed, execute this continuation method to construct the next IDialog<R>.

Template Parameters
TThe type of the antecedent dialog.
RThe type of the next dialog.
Parameters
contextThe bot context.
itemThe result of the previous IDialog<T>.
Returns
A task that represents the next IDialog<R>.
static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.ContinueWith< T, R > ( this IDialog< T >  antecedent,
Continuation< T, R >  continuation 
)
inlinestatic

When the antecedent IDialog<T> has completed, execute the continuation to produce the next IDialog<R>.

Template Parameters
TThe type of the antecedent dialog.
RThe type of the next dialog.
Parameters
antecedentThe antecedent IDialog<T>.
continuationThe continuation to produce the next IDialog<R>.
Returns
The next IDialog<R>.

Definition at line 155 of file Chain.cs.

static ICase<T, R> Microsoft.Bot.Builder.Dialogs.Chain.Default< T, R > ( ContextualSelector< T, R >  selector)
inlinestatic

Constructs a case to use as the default.

Template Parameters
TThe type of incoming value to case.
RThe type of the object returned by selector.
Parameters
selectorThe contextual selector of the case.
Returns
The case.

Definition at line 428 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.DefaultIfException< T > ( this IDialog< T >  antecedent)
inlinestatic

When the antecedent IDialog<T> has completed, stop the propagation of Exception.

Template Parameters
TThe type returned by the antecedent dialog.
Parameters
antecedentThe antecedent dialog IDialog<T>.
Returns
The default value of T if there is an Exception.

Definition at line 323 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.DefaultIfException< T, E > ( this IDialog< T >  antecedent)
inlinestatic

When the antecedent IDialog<T> has completed, stop the propagation of an exception of E .

Template Parameters
TThe type returned by the antecedent dialog.
EThe type of exception to swallow.
Parameters
antecedentThe antecedent dialog IDialog<T>.
Returns
The default value of T if there is an exception of type E .
Type Constraints
E :Exception 

Definition at line 312 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Do< T > ( this IDialog< T >  antecedent,
Func< IBotContext, IAwaitable< T >, Task >  callback 
)
inlinestatic

Execute a side-effect after a IDialog<T> completes.

Template Parameters
TThe type of the dialog.
Parameters
antecedentThe antecedent IDialog<T>.
callbackThe callback method.
Returns
The antecedent dialog.

Definition at line 82 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Fold< T > ( this IDialog< IEnumerable< IDialog< T >>>  antecedent,
Func< T, T, T >  folder 
)
inlinestatic

Fold items from an enumeration of dialogs.

Template Parameters
TThe type of the dialogs in the enumeration produced by the antecedent dialog.
Parameters
antecedentThe antecedent dialog that produces an enumeration of IDialog<T>.
folderThe accumulator for the dialog enumeration.
Returns
The accumulated result.

Definition at line 377 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.From< T > ( Func< IDialog< T >>  MakeDialog)
inlinestatic

Construct a IDialog<T> that will make a new copy of another IDialog<T> when started.

Template Parameters
TThe type of the dialog.
Parameters
MakeDialogThe dialog factory method.
Returns
The new dialog.

Definition at line 70 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Loop< T > ( this IDialog< T >  antecedent)
inlinestatic

Loop the IDialog<T> forever.

Parameters
antecedentThe antecedent IDialog<T>.
Returns
The looping dialog.

Definition at line 216 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.PostEvent< T, E > ( this IDialog< T >  antecedent,
E @  event 
)
inlinestatic

When the antecedent IDialog<T> has completed, post the item to the event queue.

Template Parameters
TThe type of the antecedent dialog.
EThe type of the event.
Parameters
antecedentThe antecedent IDialog<T>.
eventThe event.
Returns
The result from the antecedent IDialog<T>.

Definition at line 142 of file Chain.cs.

static IDialog<IMessageActivity> Microsoft.Bot.Builder.Dialogs.Chain.PostToChain ( )
inlinestatic

Post the message from the user to Chain.

The returned IDialog<T> can be used as the root dialog for a chain.

Returns
The dialog that dispatches the incoming message from the user to chain.

Definition at line 129 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.PostToUser< T > ( this IDialog< T >  antecedent)
inlinestatic

Post to the user the result of a IDialog<T>.

Template Parameters
TThe type of the dialog.
Parameters
antecedentThe antecedent IDialog<T>.
Returns
The antecedent dialog.

Definition at line 106 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Return< T > ( item)
inlinestatic

Creates a IDialog<T> that returns a value.

The type of the value should be serializable.

Template Parameters
TType of the value.
Parameters
itemThe value to be wrapped.
Returns
The IDialog<T> that wraps the value.

Definition at line 352 of file Chain.cs.

static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.Select< T, R > ( this IDialog< T >  antecedent,
Func< T, R >  selector 
)
inlinestatic

When the antecedent IDialog<T> has completed, project the result into a new IDialog<R>.

Template Parameters
TThe type of the antecedent dialog.
RThe type of the projected dialog.
Parameters
antecedentThe antecedent dialog IDialog<T>.
selectorThe projection function from T to R .
Returns
The result IDialog<R>.

Definition at line 168 of file Chain.cs.

static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.SelectMany< T, C, R > ( this IDialog< T >  antecedent,
Func< T, IDialog< C >>  function,
Func< T, C, R >  projection 
)
inlinestatic

When the antecedent IDialog<T> has completed, execute the next IDialog<C>, and use the projection to combine the results.

Template Parameters
TThe type of the antecedent dialog.
CThe type of the intermediate dialog.
RThe type of the projected dialog.
Parameters
antecedentThe antecedent dialog IDialog<T>.
functionThe factory method to create the next dialog IDialog<C>.
projectionThe projection function for the combination of the two dialogs.
Returns
The result IDialog<R>.

Definition at line 206 of file Chain.cs.

static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.Switch< T, R > ( this IDialog< T >  antecedent,
params ICase< T, R >[]  cases 
)
inlinestatic

When the antecedent IDialog<T> has completed, go through each ICase<T, R> and run the ContextualSelector<T, R>" of the first <see cref="ICase{T, R}"/> that the returned value by the antecedent dialog satisfies.

Template Parameters
TThe type of the antecedent dialog.
RThe type of the Dialog returned by ContextualSelector<T, R>
Parameters
antecedentThe antecedent dialog IDialog<T>.
casesCases for the switch
Returns
The result IDialog<R>.

Definition at line 338 of file Chain.cs.

static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.Then< T, R > ( this IDialog< T >  Antecedent,
Func< IBotContext, IAwaitable< T >, Task< R >>  Action 
)
inlinestatic

Execute an action after the IDialog<T> completes.

Template Parameters
TThe type of the dialog.
RThey type returned by action.
Parameters
AntecedentThe antecedent IDialog<T>.
ActionThe action that will be called after the antecedent dialog completes.
Returns
The antecedent dialog.

Definition at line 95 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Unwrap< T > ( this IDialog< IDialog< T >>  antecedent)
inlinestatic

When the antecedent IDialog<T> where T is IDialog<T> completes, unwrap the result into a new IDialog<T>.

Template Parameters
TThe type of the antecedent dialog.
Parameters
antecedentThe antecedent dialog IDialog<T> where T is IDialog<T>.
Returns
An IDialog<T>.

Definition at line 191 of file Chain.cs.

static IDialog<object> Microsoft.Bot.Builder.Dialogs.Chain.Void< T > ( this IDialog< T >  antecedent,
IDialogStack  stack 
)
inlinestatic

Call the voided IDialog<T>, ignore the result, then restart the original dialog wait.

(value types don't support generic parameter variance - so this reflection-based method may not work) It's okay to loose type information (i.e. IDialog{object}) because voided dialogs are called with a null ResumeAfter<T> because they are hacking the stack to satisfy the wait of the interrupted dialog.

Template Parameters
TThe type of the voided dialog.
Parameters
antecedentThe voided dialog.
stackThe dialog stack.
Returns
The dialog that produces the item to satisfy the original wait.

Definition at line 255 of file Chain.cs.

static IDialog<R> Microsoft.Bot.Builder.Dialogs.Chain.Void< T, R > ( this IDialog< T >  antecedent)
inlinestatic

Call the voided IDialog<T>, ignore the result, then restart the original dialog wait.

The purpose of this method is to wrap an antecedent dialog A with a new dialog D to push on the stack on top of the existing stack top dialog L.

  1. D will call A.
  2. D will receive the value of A when A is done.
  3. D will re-initiate the typed wait (often for a message) for which a method of L was waiting
  4. D will receive that value of the re-initiated typed wait.
  5. D will return that value of the typed wait to L. This depends on the symmetry of IDialogStack.Done and IDialogStack.Wait in how they satisfy typed waits.
Template Parameters
TThe type of the voided dialog.
RThe type of the original dialog wait.
Parameters
antecedentThe voided dialog.
Returns
The dialog that produces the item to satisfy the original wait.

Definition at line 238 of file Chain.cs.

static IDialog<IMessageActivity> Microsoft.Bot.Builder.Dialogs.Chain.WaitToBot< T > ( this IDialog< T >  antecedent)
inlinestatic

Post to the chain the message to the bot after the antecedent completes.

Template Parameters
TThe type of the dialog.
Parameters
antecedentThe antecedent IDialog<T>.
Returns
The dialog representing the message sent to the bot.

Definition at line 117 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.Where< T > ( this IDialog< T >  antecedent,
Func< T, bool >  predicate 
)
inlinestatic

When the antecedent IDialog<T> has completed, evaluate the predicate and decide whether to continue.

Template Parameters
TThe type of the antecedent dialog.
Parameters
antecedentThe antecedent dialog IDialog<T>.
predicateThe predicate to decide whether to continue the chain.
Returns
The result from the antecedent IDialog<T> or its cancellation, wrapped in a IDialog<T>.

Definition at line 180 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.While< T > ( this IDialog< T >  initial,
Func< T, IDialog< bool >>  test,
Func< T, IDialog< T >>  body 
)
inlinestatic

Create a IDialog<T> that represents a while loop.

Template Parameters
TThe type of the value.
Parameters
initialThe value if test is never true.
testThe test to enter the while loop body .
bodyThe body of the while loop.
Returns
Zero or the last value returned by the body of the while loop.

Definition at line 365 of file Chain.cs.

static IDialog<T> Microsoft.Bot.Builder.Dialogs.Chain.WithScorable< T, Item, Score > ( this IDialog< T >  antecedent,
IScorable< Item, Score >  scorable 
)
inlinestatic

Decorate a dialog with a scorable, so that a scorable can participate on the dialog stack.

Template Parameters
TThe type of the dialog.
ItemThe type of the item scored by the scorable.
ScoreThe type of the scope produced by the scorable.
Parameters
antecedentThe antecedent dialog.
scorableThe scorable.
Returns
The dialog augmented with the scorables.

Definition at line 391 of file Chain.cs.


The documentation for this class was generated from the following file: