Method Execute
Execute<T>(Func<ResultEventArgs<T>, bool>, EventHandler<ResultEventArgs<T>>?, ResultEventArgs<T>, Action?)
Executes a single-phase CWP workflow with a virtual method, event, and optional default action.
public static bool? Execute<T>(Func<ResultEventArgs<T>, bool> onMethod, EventHandler<ResultEventArgs<T>>? eventHandler, ResultEventArgs<T> args, Action? defaultAction = null)
Parameters
onMethodFunc<ResultEventArgs<T>, bool>The virtual method invoked first, returning true to mark the workflow as handled.
eventHandlerEventHandler<ResultEventArgs<T>>The event handler to invoke, or null if no handlers are subscribed.
argsResultEventArgs<T>The event arguments containing a result and handled status.
defaultActionActionThe default action to execute if the workflow is not handled, or null if none.
Returns
- bool?
True if the workflow was handled, false if not, or null if no event handlers are subscribed.
Type Parameters
TThe type of the result in the event arguments.
Examples
ResultEventArgs<bool> args = new();
Func<ResultEventArgs<bool>, bool> onAccepting = _ => false;
EventHandler<ResultEventArgs<bool>>? acceptingHandler = null;
Action? defaultAction = () => args.Result = true;
bool? handled = CWPWorkflowHelper.Execute(onAccepting, acceptingHandler, args, defaultAction);
Exceptions
- ArgumentNullException
Thrown if
onMethodorargsis null.