コード例 #1
0
        public void Evaluate(ExpressionInfo expression, ITaskEngine taskEngine, Action <object> callback)
        {
            TaskInfo       taskInfo   = (TaskInfo)expression.Value;
            ExpressionInfo valueInfo  = expression.Children[0];
            ExpressionInfo outputInfo = expression.Children.Length > 1 ? expression.Children[1] : null;

            if (outputInfo == null)
            {
                outputInfo = new ExpressionInfo
                {
                    Code  = ExpressionCode.Value,
                    Value = PrimitiveContract.Create(0)
                };
            }

            IExpression valueExpression = taskEngine.GetExpression(valueInfo.Code);

            expression.IsEvaluating = true;
            valueExpression.Evaluate(valueInfo, taskEngine, value =>
            {
                expression.IsEvaluating = false;
                int outputIndex         = ((PrimitiveContract <int>)outputInfo.Value).Value;
                taskEngine.Memory.WriteOutput(taskInfo.Parent.TaskId, taskInfo.TaskId, outputIndex, value);
                callback(null);
            });
        }
コード例 #2
0
 public void Evaluate(ExpressionInfo expression, ITaskEngine taskEngine, Action <object> callback)
 {
     if (expression.Value is PrimitiveContract)
     {
         PrimitiveContract primitive = (PrimitiveContract)expression.Value;
         callback(primitive.ValueBase);
     }
     else if (expression.Value is TaskInputInfo)
     {
         TaskInputInfo input = (TaskInputInfo)expression.Value;
         object        value = taskEngine.Memory.ReadOutput(input.Scope.TaskId, input.OutputTask.TaskId, input.OutputIndex);
         callback(value);
     }
     else
     {
         callback(expression.Value);
     }
 }