コード例 #1
0
        /// <summary>
        /// Executes child nodes of the current node.
        /// </summary>
        /// <param name="context">Current ExecutionContext.</param>
        /// <returns>NodeResultStatus representing the current node result.</returns>
        protected sealed override async Task <NodeResultStatus> PerformExecuteAsync(IExecutionContext <TSource> context)
        {
            if (ChildNode == null)
            {
                Logger.LogWarning("Child node of TransitionNode doesn't exist, node will be skipped.");
                return(NodeResultStatus.NotRun);
            }

            Logger.LogDebug("Creating the TransitionNode destination subject.");
            TDestination destSubject = await TransitionSourceAsync(context).ConfigureAwait(false);

            var destContext = new ExecutionContext <TDestination>(destSubject, context.GlobalOptions);

            Logger.LogDebug("Preparing to execute TransitionNode child.");
            NodeResult destResult = await ChildNode.ExecuteAsync(destContext).ConfigureAwait(false);

            var exceptions = destResult.GetFailExceptions().ToList();

            if (exceptions.Count > 0)
            {
                Logger.LogInformation("TransitionNode child returned {0} exceptions.", exceptions.Count);
                context.ParentResult.Exception = exceptions.Count == 1 ? exceptions[0] : new AggregateException(exceptions);
            }
            Logger.LogDebug("Creating the TransitionNode destination result.");
            var resultSubject = await TransitionResultAsync(context, destResult).ConfigureAwait(false);

            if (!context.Subject.Equals(resultSubject))
            {
                Logger.LogDebug("Source subject has changed, calling ChangeSubject.");
                context.ChangeSubject(resultSubject);
            }

            return(destResult.Status);
        }
コード例 #2
0
ファイル: TestClasses.cs プロジェクト: sambsp/Banzai
        protected override Task <NodeResultStatus> PerformExecuteAsync(IExecutionContext <TestObjectA> context)
        {
            context.ChangeSubject(new TestObjectA()
            {
                TestValueString = "New Instance"
            });

            return(Task.FromResult(NodeResultStatus.Succeeded));
        }