Bolt 2 will support delegates with three additional unit types.

Create Delegate

Create Delegate will be a preconfigured unit available for any delegate type included in the Extraction process (e.g. Handle Func<T, TResult>). It will support generic delegate construction thanks to the new generic construction support (see details below).

Create Delegate will be the unit responsible for mapping the actual delegate logic to a delegate object output. For example, the handle delegate unit for Func<int, string> would have this signature:

Inputs


(None)

Outputs


Whenever the delegate is triggered, the Parameter ports (e.g. T) will be assigned with the passed arguments and the Enter port will get triggered. The first output port, the delegate object itself, is meant to be passed to the Trigger Delegate unit or any reflected unit that expects a delegate of this type.

Delegate Return

Bolt will support delegates with and without return values. By default, a delegate with a return value will return the default value for that return type (e.g. 0 for integer)­. That is unless, somewhere along the delegate execution, the Delegate Return unit was entered. This unit simply assigns the return value of the delegate. It is also a preconfigured unit that gets included for any delegate type in the extraction process (e.g. Func<T, TResult> Return). For example:

Inputs


Outputs


The delegate type of the return unit must match the delegate type of the handle delegate unit. Multiple delegate return units are allowed within the flow of a single handle delegate unit; the last assigned return value will be used.

Trigger Delegate

The Trigger Delegate unit will also be a preconfigured unit available for any delegate type included in the Extraction process (e.g. Trigger Func<T, TResult>). Its signature will provide the required arguments for the specified delegate type and specify when to trigger it, then return the result of the delegate, if any. For example, for Func<int, string>:

Inputs


Outputs


Delegate Port Display

Delegate ports, which are just value ports internally, will display slightly differently. The circle will be replaced by a diamond shape (◇) and it will display before any other port.