internal BlockTraceResult(StackBlockBase <TOperationEvent> stackBlock, IBlockResult blockResult) { Tag = stackBlock.Tag; Input = stackBlock.Input; Result = blockResult.Result; InnerStackTrace = stackBlock.InnerStackTrace ?? Enumerable.Empty <BlockTraceResult <TOperationEvent> >(); Events = stackBlock.Events.ToList(); if (blockResult.ExecutionTime == null) { Time = new ExecutionTime(); } else { Time = blockResult.ExecutionTime; } }
/// <summary> /// Handle current block result and set next block to execute /// </summary> /// <param name="block">The execution block</param> /// <param name="blockResult">The execution block result</param> public void HandleBlockResultAndSetNext(StackBlockBase <TInput, TState, TOperationEvent> block, IBlockResult blockResult) { PreviousBlockSpec = CurrentBlockSpec; //Add to stack trace //Should we add trace to empty event blocks? To event blocks? StackTrace.Add(new BlockTraceResult <TOperationEvent>(block, blockResult)); //Handle Reset state in case of reset State = blockResult.Target.FlowTarget == BlockFlowTarget.Reset ? (blockResult.Target.ResetStateSet ? (TState)Convert.ChangeType(blockResult.Target.State, typeof(TState)) : default(TState)) : block.StackState; //Check fail state if (options.FailOnException && block.Events.HasUnhandledErrors) { IsFail = true; } //Override result is only applicable on Complete. Cache here in case of finally OverrideResult = blockResult.Target.OverrideResult; //Set next input NextInput = blockResult.GetNextInput(); //Get next block to execute CurrentBlockSpec = IsFail ? blocks.GotoEnd(CurrentBlockSpec.Index) : GetNext(CurrentBlockSpec, blockResult.Target); //If complete set overriden result if any if (CurrentBlockSpec == null && OverrideResult.HasValue) { //Set last result LastResult = OverrideResult; blockResult.OverrideResult(OverrideResult); } else { //Set last result LastResult = blockResult.Result; } }