protected TreeMachine.PassWF Pass(TreeMachine.IWorkflow child) => new TreeMachine.PassWF(child);
protected TreeMachine.IWorkflow While(TreeMachine.IWorkflow cond, TreeMachine.IWorkflow child) => Pass(Loop(If(cond, Pass(child), Fail())));
protected TreeMachine.NotWF Not(TreeMachine.IWorkflow child) => new TreeMachine.NotWF(child);
protected TreeMachine.ForeverWF Forever(TreeMachine.IWorkflow child) => new TreeMachine.ForeverWF(child);
protected TreeMachine.WhileWF While(Func <TreeMachine.IContext, bool> pred, TreeMachine.IWorkflow child) => new TreeMachine.WhileWF(pred, child);
protected TreeMachine.TimeoutWF Timeout(TimeSpan delay, TreeMachine.IWorkflow child, TreeMachine.IWorkflow onTimeout = null) => new TreeMachine.TimeoutWF(_ => delay, child, onTimeout ?? Fail());
protected TreeMachine.IWorkflow Delay(TimeSpan delay, TreeMachine.IWorkflow after = null) => Delay(_ => delay, after ?? Ok());
protected TreeMachine.ReceiveAnyWF ReceiveAny(Func <object, bool> shouldHandle, TreeMachine.IWorkflow child = null) => new TreeMachine.ReceiveAnyWF(shouldHandle, child);
protected TreeMachine.ReceiveWF <T> Receive <T>(TreeMachine.IWorkflow child = null) => new TreeMachine.ReceiveWF <T>(child);
protected TreeMachine.IfWF If(Func <TreeMachine.IContext, bool> pred, TreeMachine.IWorkflow @then = null, TreeMachine.IWorkflow @else = null) => new TreeMachine.IfWF(Condition(pred), @then, @else);
protected TreeMachine.ReceiveAnyWF ReceiveAny(TreeMachine.IWorkflow child = null) => new TreeMachine.ReceiveAnyWF(child);
protected TreeMachine.IfWF If(TreeMachine.IWorkflow cond, TreeMachine.IWorkflow @then = null, TreeMachine.IWorkflow @else = null) => new TreeMachine.IfWF(cond, @then, @else);
protected void StartWith(TreeMachine.IWorkflow wf, TData data) { Machine = new TreeMachine(data, null, this); Machine.Run(wf); }
protected TreeMachine.IWorkflow Delay(Func <TreeMachine.IContext, TimeSpan> delay, TreeMachine.IWorkflow after = null) => new TreeMachine.TimeoutWF(delay, Never(), after ?? Ok());
protected TreeMachine.AfterWF After(TreeMachine.IWorkflow child, TreeMachine.IWorkflow after) => new TreeMachine.AfterWF(child, after);
protected TreeMachine.ReceiveWF <T> Receive <T>(Func <T, bool> shouldHandle, TreeMachine.IWorkflow child = null) => new TreeMachine.ReceiveWF <T>(shouldHandle, child);
protected TreeMachine.SpawnWF Spawn(TreeMachine.IWorkflow child) => new TreeMachine.SpawnWF(child);
protected TreeMachine.LoopWF Loop(TreeMachine.IWorkflow child) => new TreeMachine.LoopWF(child);
protected TreeMachine.TimeoutWF Timeout(Func <TreeMachine.IContext, TimeSpan> delay, TreeMachine.IWorkflow child, TreeMachine.IWorkflow onTimeout = null) => new TreeMachine.TimeoutWF(delay, child, onTimeout ?? Fail());
private TreeMachine.IWorkflow WithDoneAndDone(TreeMachine.IWorkflow wf) => AllSucceed( AnySucceed( Done(), wf), Execute(_ => Sender.Tell("DONE")));